2011-03-01 57 views

回答

5

這是因爲ToolStripComboBox派生自ToolStripControlHost,而不是ComboBox。您需要使用其Control屬性才能進入組合框。像這樣:

public partial class Form1 : Form { 
    public Form1() { 
     InitializeComponent(); 
     ComboBox box = (ComboBox)toolStripComboBox1.Control; 
     box.DrawMode = DrawMode.OwnerDrawVariable; 
     box.MeasureItem += new MeasureItemEventHandler(box_MeasureItem); 
     box.DrawItem += new DrawItemEventHandler(box_DrawItem); 
    } 

    void box_DrawItem(object sender, DrawItemEventArgs e) { 
     // etc.. 
    } 

    void box_MeasureItem(object sender, MeasureItemEventArgs e) { 
     // etc.. 

    } 
} 

用你需要測量的代碼填寫事件處理程序,並用他們自己的字體樣式繪製字體名稱。

相關問題