prevent dropdown area from opening of combobox control in windows forms

前端 未结 1 343
猫巷女王i
猫巷女王i 2021-01-27 00:49

I have a custom combo box control in windows forms. I want to achieve a functionality wherein based on some condition the dropdown area should not be displayed i.e. I need to pr

1条回答
  •  旧巷少年郎
    2021-01-27 01:33

    Just add your condition to that if statement:

    public class CustomComboBox : ComboBox
    {
      protected override void WndProc( ref  Message m )
      {
        if(yourCondition && 
           (m.Msg == 0x201 || // WM_LBUTTONDOWN
            m.Msg == 0x203)) // WM_LBUTTONDBLCLK
          return;
        base.WndProc( ref m );
      }
    }
    

    0 讨论(0)
提交回复
热议问题