473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

.Net combo box - what is "opposite" of DropDown event?

I'm working on an owner-drawn combo box which has extended
functionality. I have to do something to the dropdown list when it
drops down, then undo it when it is closed up again. But I can't see
an event which seems to be a "CloseUp" event - is there such an event?
Surely there must be!

Aug 8 '06 #1
4 2503
Steve Marshall wrote:
I'm working on an owner-drawn combo box which has extended
functionality. I have to do something to the dropdown list when it
drops down, then undo it when it is closed up again. But I can't see
an event which seems to be a "CloseUp" event - is there such an event?
Surely there must be!
..NET 2.0: DropDownClosed
Earlier: Override the WndProc message and watch for message
CB_SHOWDROPDOWN (this same message is sent on both drop and close, so it
only means 'close' when it's sent while the dropdown is dropped down).

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Aug 8 '06 #2

"Larry Lard" <la*******@googlemail.comwrote in message
news:4j************@individual.net...
Steve Marshall wrote:
>I'm working on an owner-drawn combo box which has extended
functionality. I have to do something to the dropdown list when it
drops down, then undo it when it is closed up again. But I can't see
an event which seems to be a "CloseUp" event - is there such an event?
Surely there must be!

.NET 2.0: DropDownClosed
Earlier: Override the WndProc message and watch for message
CB_SHOWDROPDOWN (this same message is sent on both drop and close, so it
only means 'close' when it's sent while the dropdown is dropped down).
CB_SHOWDROPDOWN is not a notification message. It's used to drop down the
list programatically. To know when the list closes up you should use the
CBN_CLOSEUP notification. Here's the code for that:

Public Class ComboBoxEx
Inherits ComboBox
Private Const WM_USER As Integer = &H400
Private Const WM_COMMAND As Integer = &H111
Private Const OCM__BASE As Integer = WM_USER + &H1C00
Private Const OCM_COMMAND As Integer = OCM__BASE + WM_COMMAND

Private Function HIWORD(ByVal value As Integer) As Short
Return CShort(New System.Drawing.Point(value).Y)
End Function

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = OCM_COMMAND Then
Dim code As Integer = HIWORD(m.WParam.ToInt32)
If code = CBN_CLOSEUP Then
OnCloseUp(EventArgs.Empty)
End If
End If
MyBase.WndProc(m)
End Sub

Protected Overridable Sub OnCloseUp(ByVal e As System.EventArgs)
RaiseEvent CloseUp(Me, e)
End Sub

Public Event CloseUp As EventHandler
End Class

/claes
Aug 8 '06 #3
Many thanks Claes. I had tried what Larry suggested, but my WndProc
override routine never saw the CB_SHOWDROPDOWN message, so I was about
to post a further question about it. Your contribution is perfectly
timed!

Aug 9 '06 #4
Claes Bergefall wrote:
"Larry Lard" <la*******@googlemail.comwrote in message
news:4j************@individual.net...
>Steve Marshall wrote:
>>I'm working on an owner-drawn combo box which has extended
functionality. I have to do something to the dropdown list when it
drops down, then undo it when it is closed up again. But I can't see
an event which seems to be a "CloseUp" event - is there such an event?
Surely there must be!
.NET 2.0: DropDownClosed
Earlier: Override the WndProc message and watch for message
CB_SHOWDROPDOWN (this same message is sent on both drop and close, so it
only means 'close' when it's sent while the dropdown is dropped down).

CB_SHOWDROPDOWN is not a notification message. It's used to drop down the
list programatically. To know when the list closes up you should use the
CBN_CLOSEUP notification. Here's the code for that:
That's what I deserve for skimming API docs too quickly, I suppose.
Thanks for sorting me out.
--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Aug 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jan Danielsson | last post by:
Hello all, I have a list of integers: q = which I would like to convert to a string: "1,2,4,7,9"
27
by: Ron Adam | last post by:
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) It occurred to me (a...
24
by: Alf P. Steinbach | last post by:
The eighth chapter (chapter 2.1) of my attempted Correct C++ tutorial is now available, although for now only in Word format -- comments welcome! Use the free & system-independent Open Office...
32
by: Christopher Benson-Manica | last post by:
Is the following code legal, moral, and advisable? #include <iostream> class A { private: int a; public: A() : a(42) {}
6
by: PaulR | last post by:
We have seen this a lot, but have just experienced the opposite to what we have always seen previously, so this has prompted me to ask a high level - why do we get this behaviour? If we re-write...
388
by: maniac | last post by:
Hey guys, I'm new here, just a simple question. I'm learning to Program in C, and I was recommended a book called, "Mastering C Pointers", just asking if any of you have read it, and if it's...
15
by: Joe Van Dyk | last post by:
Can someone explain what a heap and what a stack is? And why I should care? I used to know, but then I forgot. And I can't seem to find it in the C++ FAQ. I keep reading how allocating from...
11
by: arnuld | last post by:
i have created a new temperature conversion programme. it converts a temperature from Fahrenheit to Celsius or from Celsius to Fahrenheit at user's will. tell em if i need some improvements: ...
3
by: Jukka K. Korpela | last post by:
Some time ago in this group, someone suggested that we should develop a "different" user style sheet to demonstrate what a user style sheet or a browser style sheet _could_ do. I guess the idea was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.