我读过这个主题http://technicalsol.blogspot.com/2009/03/combobox-set-font-style.html with comboBox,但在toolstripComboBox not exist event draw_item中我需要你的帮助。我正在用C#编写简单的写字板。
发布于 2011-03-01 21:56:15
这是因为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..
}
}用您需要测量的代码填充事件处理程序,并以其自己的字体样式绘制字体名称。
https://stackoverflow.com/questions/5155049
复制相似问题