2011-05-16 82 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;