【问题标题】:toolStripComboBox set font style?toolStripComboBox 设置字体样式?
【发布时间】:2011-03-01 13:21:15
【问题描述】:

我用组合框阅读了这个主题http://technicalsol.blogspot.com/2009/03/combobox-set-font-style.html,但在工具条组合框中不存在事件draw_item 我需要你的帮助。我正在用 C# 编写简单的写字板。

【问题讨论】:

标签: c# .net toolstrip


【解决方案1】:

这是因为 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..

    }
}

使用您需要测量的代码填写事件处理程序,并以自己的字体样式绘制字体名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-23
    • 2014-06-23
    • 1970-01-01
    • 2011-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多