2011-05-16 48 views

回答

1

您需要的ToolStripItem.DisplayStyle属性设置为Image,然后设置image属性

下面是从MSDN其中

  • 从文件
  • 获取图像中的采样设置样式图像和文字
  • 将图像与MiddleLeft对齐
  • 设置该图像的名称
  • 设置文本对齐MiddleRight
  • 设置文本
  • 并增加了一个Click事件处理程序

样品

this.toolStripButton1.Image = Bitmap.FromFile("c:\\NewItem.bmp"); 
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText; 
this.toolStripButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 
this.toolStripButton1.Name = "toolStripButton1"; 
this.toolStripButton1.Text = "&New"; 
this.toolStripButton1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); 
1

您正在寻找的(击鼓声......)                                      Image财产

0

Image物业 DisplayStyle必须设置为ImageAndText或者Image

+0

我不想只有图像,我想要两个文本项目和左侧的图像!如果我的朋友用代码解释,我会非常感谢。 – 2011-05-16 15:37:21

1

试试这个:

myContextMenuStrip.ShowImageMargin = true;