How to prevent ComboBox from dropping down on click

  • Thread starter Matthias Menningen via .NET 247
  • Start date
M

Matthias Menningen via .NET 247

The Combobox control supplied by DOTNET configured as dropdown list
behaves in the following way: When the user clicks into the box it
immediately drops down.

Normally dropdown boxes should drop down only when the dropdown button of
the control is clicked. Most applications e. g. in Mocrosoft Office
do it this way. The ADO-bound Combo box sypplied with VB6 conformed with
this beaviour.

How can I change the behaviour of the standard DOTNET Combobox control?

I already tried the following (in the WndProc method):
o I supressed the WM_LBUTTONDOWN message. This suppresses, as expected,
all subsequent messages that fire the dropdown event and draw the
dropdown list etc.
However, it also prevents the box from receiving the focus.

o I tried to suppress all or selected messges that seem to by triggered by
WM_LBUTTONDOWN message using the following code (VB):
Static SuppressMsgs
...
Select Case m.Msg
Case WM_LBUTTONDOWN
...
SuppressMsgs = True
MyBase.WndProc(m)
SuppressMsgs = False
...

Case (other message)
If Not SuppressMsgs Then
MyBase.WndProc(m)
End If

...

This also does not have the desired effect. The box for the
dropdown list always shows up. Depending on which messages were
suppressed it is empty or has zero height.
 
P

Pete

ummmm, I would consider that an asset to my application if the user only has to click the box to get
the drop down instead of hunting down the arrow which could be positioned all the way across the
screen if the box is wide....

With that said, try changing the DropDownStyle to DropDown: if I remember correctly, the curser will
now be an I bar and will allow the user to be able to type into the box.

/Pete.



| The Combobox control supplied by DOTNET configured as dropdown list
| behaves in the following way: When the user clicks into the box it
| immediately drops down.
|
| Normally dropdown boxes should drop down only when the dropdown button of
| the control is clicked. Most applications e. g. in Mocrosoft Office
| do it this way. The ADO-bound Combo box sypplied with VB6 conformed with
| this beaviour.
|
| How can I change the behaviour of the standard DOTNET Combobox control?
|
| I already tried the following (in the WndProc method):
| o I supressed the WM_LBUTTONDOWN message. This suppresses, as expected,
| all subsequent messages that fire the dropdown event and draw the
| dropdown list etc.
| However, it also prevents the box from receiving the focus.
|
| o I tried to suppress all or selected messges that seem to by triggered by
| WM_LBUTTONDOWN message using the following code (VB):
| Static SuppressMsgs
| ...
| Select Case m.Msg
| Case WM_LBUTTONDOWN
| ...
| SuppressMsgs = True
| MyBase.WndProc(m)
| SuppressMsgs = False
| ...
|
| Case (other message)
| If Not SuppressMsgs Then
| MyBase.WndProc(m)
| End If
|
| ...
|
| This also does not have the desired effect. The box for the
| dropdown list always shows up. Depending on which messages were
| suppressed it is empty or has zero height.
| --------------------------------
| From: Matthias Menningen
|
| -----------------------
| Posted by a user from .NET 247 (http://www.dotnet247.com/)
|
| <Id>L/fqZ3UeoUGRn50RgoZLOw==</Id>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top