0
我讀了這個主題http://technicalsol.blogspot.com/2009/03/combobox-set-font-style.html與comboBox,但在toolstripComboBox不存在事件draw_item 我需要你的幫助。我正在用C#編寫簡單的寫字板。toolStripComboBox設置字體樣式?
我讀了這個主題http://technicalsol.blogspot.com/2009/03/combobox-set-font-style.html與comboBox,但在toolstripComboBox不存在事件draw_item 我需要你的幫助。我正在用C#編寫簡單的寫字板。toolStripComboBox設置字體樣式?
這是因爲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..
}
}
用你需要測量的代碼填寫事件處理程序,並用他們自己的字體樣式繪製字體名稱。
有DrawItem http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.drawitem.aspx,如果您使用WinForms – Stecya 2011-03-01 13:23:34