.NETGURU
detecting combobox list closure
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

adam@twv.org (VIP)
Is there a way of detecting when a combobox list closure?

The DropDown event only fires when the list opened not when it is closed,
for example by the user clicking outside the combobox.

I wondered about deriving a class from ComboBox and overriding WndProc to
look for whatever message it must receive on closing.

Does anyone have any code samples or know where I can find a reference for
these messages?

Thanks

Adam

Reply to this message...
 
    
Imran Koradia (VIP)
You are right on track. I don't have a complete code sample on hand but
here's how you can go about it:

Create a new inherited control that inherits from ComboBox. In the new
control, override the WndProc method as follows:

Private Const CB_SHOWDROPDOWN As Integer = &H14F

Protected Overrides Sub WndProc( _
ByRef m As Message)
if m.Msg = CB_SHOWDROPDOWN then
if CBool(m.WParam) = True then
Console.WriteLine("showing listbox of combobox")
else
Console.WriteLine("hiding listbox of combobox")
end if
end if
End Sub

The constant values are in the header winuser.h. Here's a link about the
CB_SHOWDROPDOWN message:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/comboboxes/comboboxreference/comboboxmessages/cb_showdropdown.asp

hope that helps..
Imran.

"Click here to reveal e-mail address" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Imran Koradia (VIP)
Ofcourse, don't forget to call MyBase.WndProc at the end of the procedure so
that the messages are sent to the base control or else your combobox won't
work at all!

[Original message clipped]

Reply to this message...
 
    
adam@twv.org (VIP)
Thanks for this.

I have tried it. One problem was that despite the docs saying that wParam is
a bool, it throws an invalidCast exception when you try to convert it, but I
got round that with IntPtr.ToInt32().

However, the more significant problem is that the combobox doesnt seem to
receive a message, at least not CB_SHOWDROPDOWN when it closes, only when it
opens. My reading of the docs is that this is the right message, with
different values in wParam depending on whether it is opening or closing.

Does anyone know which is the message to close the dropdown?

Adam

"Imran Koradia" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Console
System.IntPtr
System.Windows.Forms.ComboBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification