Editbox portion of ComboBox gets selected automatically

后端 未结 7 1255
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 02:49

I have a small problem that has been annoying me for some hours.

In my WinForms (.NET 3.5) application I create some ComboBoxes (DropDownStyle = DropDown) in a Table

7条回答
  •  自闭症患者
    2020-12-30 03:10

    Worked for me to change the selectionLength to 0 when the WM_WINDOWPOSCHANGED gets called. Works even with the tableLayoutPanel set to %.

    protected override void WndProc(ref Message m) {
        base.WndProc(ref m);
    
        if(m.Msg == 0x0047) {   // WM_WINDOWPOSCHANGED = 0x0047 
            if (SelectionLength != 0) {
                SelectionLength = 0;
            }
        }
    }
    
    

提交回复
热议问题