请问为什么toolbar图标下的字体显示不出来?

FreeIn2006 2006-05-12 10:03:11
在TOOLBAR上加了几个按钮(有图标的),想在图标按钮下显示字体,但显示不出来,为什么?
...全文
171 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
FreeIn2006 2006-05-12
  • 打赏
  • 举报
回复
找到原因了。原来是窗体的.resx文件的问题。改变TOOLBAR后.resx文件不会自动跟着改-_-!!!

谢谢
FreeIn2006 2006-05-12
  • 打赏
  • 举报
回复
试过的,但就是不行。不知道为什么。。
lovvver 2006-05-12
  • 打赏
  • 举报
回复
你可以新建一个窗体,然后用该代码覆盖对应代码即可。
只需要改动一下namespace。
lovvver 2006-05-12
  • 打赏
  • 举报
回复
什么都不用的,等一下,我给你一个例子。
using System;
using System.Windows.Forms;

namespace ToolbarText
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ToolBar toolBar2;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.ComponentModel.IContainer components;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.panel1 = new System.Windows.Forms.Panel();
this.toolBar2 = new System.Windows.Forms.ToolBar();
this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2});
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(576, 41);
this.toolBar1.TabIndex = 0;
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// toolBarButton1
//
this.toolBarButton1.ImageIndex = 1;
this.toolBarButton1.Text = "邮件";
//
// toolBarButton2
//
this.toolBarButton2.ImageIndex = 0;
this.toolBarButton2.Text = "删除";
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.Ivory;
this.panel1.Controls.Add(this.toolBar2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 41);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(576, 47);
this.panel1.TabIndex = 1;
//
// toolBar2
//
this.toolBar2.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this.toolBar2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.toolBar2.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton3,
this.toolBarButton4});
this.toolBar2.DropDownArrows = true;
this.toolBar2.ImageList = this.imageList1;
this.toolBar2.Location = new System.Drawing.Point(0, 0);
this.toolBar2.Name = "toolBar2";
this.toolBar2.ShowToolTips = true;
this.toolBar2.Size = new System.Drawing.Size(576, 42);
this.toolBar2.TabIndex = 0;
//
// toolBarButton3
//
this.toolBarButton3.ImageIndex = 1;
this.toolBarButton3.Text = "邮件";
//
// toolBarButton4
//
this.toolBarButton4.ImageIndex = 0;
this.toolBarButton4.Text = "删除";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(576, 294);
this.Controls.Add(this.panel1);
this.Controls.Add(this.toolBar1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
FreeIn2006 2006-05-12
  • 打赏
  • 举报
回复
应该不用设置什么的吧。也找不到什么该设置的。
FreeIn2006 2006-05-12
  • 打赏
  • 举报
回复
有写TEXT的。我改过图标,但运行时却还是原来的,好像不会自动刷新。重新编译也不行。
lovvver 2006-05-12
  • 打赏
  • 举报
回复
怎么会?楼主搞错了吧
每个按钮的Text是什么?有吗?
FreeIn2006 2006-05-12
  • 打赏
  • 举报
回复
还有就是TOOLBAR好像有BUG。。。。。。

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧