Here is a proper way to do it - inherit a class from native ComboBox and override OnDropDown to raise a custom DropDownOpening event first: Public Class MyComboBox : Inherits ComboBox Public Event DropDownOpening(sender As Object, e As System.EventArgs) Protected Overrides Sub OnDropDown(e As System.EventArgs) RaiseEvent DropDownOpening(Me, e) MyBase.OnDropDown(e) End Sub End Class Private Sub MyComboBox1_DropDownOpening(sender As Object, e As System.EventArgs) Handles MyComboBox1.DropDownOpening 'reload your list here '... End Sub If you anticipate loading to take considerable time, you can wrap your reload code into a construct like this: Dim oldCursor As Cursor = MyComboBox1 .Cursor MyComboBox1 .Cursor = Cursors.WaitCursor 'reload your list here '... MyComboBox1 .Cursor = oldCursor (DoEvents is not needed to propagate cursor change)
|
Tech Blog >