Live Chat Icon For mobile
Live Chat Icon

How can I programmatically prevent the combobox from dropping

Platform: WinForms| Category: ComboBox

You can avoid the combobox dropping by overriding its WndProc method and ignoring the WM_LBUTTONDOWN and WM_LBUTTONDBLCLK.

 public class MyComboBox : ComboBox
	protected override void WndProc(ref System.Windows.Forms.Message m)
		 if(m.Msg == 0x201  //WM_LBUTTONDOWN
		    || m.Msg == 0x203)  //WM_LBUTTONDBLCLK
		base.WndProc(ref m);

Public Class MyComboBox
	Inherits ComboBox
	Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
		If m.Msg = &H201 OrElse m.Msg = &H203 Then ’WM_LBUTTONDOWN  or WM_LBUTTONDBLCLK
		End If

	End Sub ’WndProc
End Class ’MyComboBox

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.