My ComboBox class events do not fire
-
I created a new class and inherited the windows combobox. I also created a TextChanged event for the combobox. Then compiled it into a dll. When I use the combobox in a windows project the TextChanged event does not fire. What do I need to do to get it to work?
-
I created a new class and inherited the windows combobox. I also created a TextChanged event for the combobox. Then compiled it into a dll. When I use the combobox in a windows project the TextChanged event does not fire. What do I need to do to get it to work?
Can you post your TextChanged event code? It might have to do with the way you are handling it (overloads, shadows, etc.)
james commercial developer, author, speaker, dude. www.jamesfoxall.com
-
Can you post your TextChanged event code? It might have to do with the way you are handling it (overloads, shadows, etc.)
james commercial developer, author, speaker, dude. www.jamesfoxall.com
Public Class Class1 Inherits System.Windows.Forms.ComboBox Public WithEvents ComboBoxMain As New System.Windows.Forms.ComboBox Public Sub ComboBoxMain_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) End Sub End Class When the class is used in a windows project the gotfocus event never fires. What do I need to do to get this to work? Thanks.
-
Public Class Class1 Inherits System.Windows.Forms.ComboBox Public WithEvents ComboBoxMain As New System.Windows.Forms.ComboBox Public Sub ComboBoxMain_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) End Sub End Class When the class is used in a windows project the gotfocus event never fires. What do I need to do to get this to work? Thanks.
Here's what appears to have happened: You inherited a combo box - this is good. However, now your entire control is the combo box; you don't need to create another. You have also declared a combo box variable, but there is no need to do this and it will never fire because you haven't added the combo box to the Controls collection and therefor it isn't visible in the UI. Try this: 1. Take out the Public Sub and Public WithEvents statements (and the End Sub, of course). 2. In the object drop down in the upper-left corner of the code window, select (Class 1 Events). 3. In the event drop down list in the upper-right corner, select GotFocus. You will now have a GotFocus event that will fire appropriately.
james commercial developer, author, speaker, dude. www.jamesfoxall.com
-
Here's what appears to have happened: You inherited a combo box - this is good. However, now your entire control is the combo box; you don't need to create another. You have also declared a combo box variable, but there is no need to do this and it will never fire because you haven't added the combo box to the Controls collection and therefor it isn't visible in the UI. Try this: 1. Take out the Public Sub and Public WithEvents statements (and the End Sub, of course). 2. In the object drop down in the upper-left corner of the code window, select (Class 1 Events). 3. In the event drop down list in the upper-right corner, select GotFocus. You will now have a GotFocus event that will fire appropriately.
james commercial developer, author, speaker, dude. www.jamesfoxall.com
-
You're welcome. :)
james commercial developer, author, speaker, dude. www.jamesfoxall.com
-
You're welcome. :)
james commercial developer, author, speaker, dude. www.jamesfoxall.com
-
One other question about this. My combobox class has a gotfocus event. I drop that combobox class onto a form and create a gotfocus event in that form. Which gotfocus event runs first, the one back in the defining combobox class or the one in the form?
The one you defined in your class will fire before the event on the form.
james commercial developer, author, speaker, dude. www.jamesfoxall.com