Larry Lard said:
.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