如何在选择项目后删除对组合框的关注?

时间:2012-11-10 22:42:35

标签: c# winforms combobox

我想在选择项目后删除对组合框的关注。怎么做?我按如下方式设置myCombo的属性:

  

myCombo.DrawMode = OwnerDrawFixed和myCombo.DropDownStyle = DropDownList

代码如下:

    void SetComboReadOnly(object sender, DrawItemEventArgs e)
    {
        if (e.Index > -1)
        {
            e.DrawBackground();
            e.Graphics.DrawString(((ComboBox)sender).Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds);
            e.DrawFocusRectangle();
        }
    }

    void myCombo_DrawItem(object sender, DrawItemEventArgs e)
    {
        SetComboReadOnly(sender, e);
    }

0 个答案:

没有答案