Winforms: how to open combobox properly?

后端 未结 5 1005
醉梦人生
醉梦人生 2020-12-06 16:26

I have a combobox on the winforms. On Enter even I open it:

cbo.DroppedDown = true;

But if I do that the combo opens and closes immediately

5条回答
  •  情深已故
    2020-12-06 16:58

    Set DroppedDown = true in GotFocus event of the combobox. Otherwise, the dropdown list will show at wrong location.

    void cbo_GotFocus(object sender, EventArgs e)
        {
            ComboBox cbo = sender as ComboBox;
            cbo.DroppedDown = true;
        }
    

提交回复
热议问题