Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. My ComboBox class events do not fire

My ComboBox class events do not fire

Scheduled Pinned Locked Moved Visual Basic
question
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dptalt
    wrote on last edited by
    #1

    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?

    J 1 Reply Last reply
    0
    • D dptalt

      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?

      J Offline
      J Offline
      James Foxall
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • J James Foxall

        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

        D Offline
        D Offline
        dptalt
        wrote on last edited by
        #3

        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.

        J 1 Reply Last reply
        0
        • D dptalt

          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.

          J Offline
          J Offline
          James Foxall
          wrote on last edited by
          #4

          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

          D 1 Reply Last reply
          0
          • J James Foxall

            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

            D Offline
            D Offline
            dptalt
            wrote on last edited by
            #5

            That worked perfectly. Thanks a lot!

            J 1 Reply Last reply
            0
            • D dptalt

              That worked perfectly. Thanks a lot!

              J Offline
              J Offline
              James Foxall
              wrote on last edited by
              #6

              You're welcome. :)

              james commercial developer, author, speaker, dude. www.jamesfoxall.com

              D 1 Reply Last reply
              0
              • J James Foxall

                You're welcome. :)

                james commercial developer, author, speaker, dude. www.jamesfoxall.com

                D Offline
                D Offline
                dptalt
                wrote on last edited by
                #7

                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?

                J 1 Reply Last reply
                0
                • D dptalt

                  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?

                  J Offline
                  J Offline
                  James Foxall
                  wrote on last edited by
                  #8

                  The one you defined in your class will fire before the event on the form.

                  james commercial developer, author, speaker, dude. www.jamesfoxall.com

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups