toolStripComboBox设置字体样式吗? [英] toolStripComboBox set font style?

查看:110
本文介绍了toolStripComboBox设置字体样式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了此主题 http://technicalsol.blogspot.带有comboBox的com/2009/03/combobox-set-font-style.html ,但在toolstripComboBox中不存在事件draw_item 我需要你的帮助.我正在用C#编写简单的写字板.

I read this topic http://technicalsol.blogspot.com/2009/03/combobox-set-font-style.html with comboBox but in toolstripComboBox not exist event draw_item I need your help. I am writing simple wordpad by C#.

推荐答案

这是因为ToolStripComboBox派生自ToolStripControlHost,而不是ComboBox.您需要使用其Control属性进入组合框.像这样:

This is because ToolStripComboBox derives from ToolStripControlHost, not ComboBox. You need to use its Control property to get to the combo box. Like this:

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..

    }
}

在事件处理程序中填写您需要使用自己的字体样式来测量和绘制字体名称的代码.

Fill in the event handlers with the code you need to measure and draw the font names in their own font style.

这篇关于toolStripComboBox设置字体样式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆