我用comboBox 阅读了这个主题http://technicalsol.blogspot.com/2009/03/combobox-set-font-style.html但是在toolstripComboBox中不存在事件draw_item我需要你的帮助.我正在用C#编写简单的wordpad.
这是因为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..
}
}
Run Code Online (Sandbox Code Playgroud)
使用您需要测量的代码填充事件处理程序,并以自己的字体样式绘制字体名称.
| 归档时间: |
|
| 查看次数: |
1651 次 |
| 最近记录: |