0

I want to remove focus on Combo Box after item selected. How to do it? I set properties of myCombo as follows:

myCombo.DrawMode=OwnerDrawFixed and myCombo.DropDownStyle=DropDownList

Code as follows:

    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);
    }
Devin Burke
  • 13,642
  • 12
  • 55
  • 82
YD4
  • 99
  • 1
  • 4
  • 12
  • 1
    Set it to another control? Also, why? You would break user experience consistency - users generally don't like it. – Victor Zakharov Nov 10 '12 at 23:03
  • http://stackoverflow.com/questions/1140250/how-to-remove-focus-from-a-textbox-in-c-winforms – Yatrix Nov 10 '12 at 23:06
  • @Neolisk, I see combo with DropDownList style behavior like that. Once we select an item, then the focus will be lost after item selected. Thanks for suggestion, I've tried to move focus to label and succeed. – YD4 Nov 10 '12 at 23:20
  • @YD4: Great! Should I post it as an answer then? :) – Victor Zakharov Nov 10 '12 at 23:36

0 Answers0