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. Dynamic control events

Dynamic control events

Scheduled Pinned Locked Moved Visual Basic
questiondata-structuresjsonhelp
4 Posts 3 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.
  • H Offline
    H Offline
    H is here
    wrote on last edited by
    #1

    Hello Could some of you, great people, please help me? I have a array of controls and I would like to get the events. Here is the code: Dim pic(10) as system.windows.forms.picturebox For a=0 to 10 pic(a)=new system.windows.forms.picturebox ' the rest of the properties me.panel1.controls.add(pic(a)) next How can I catch the events of the 'pic' controls? Thanks

    D J H 3 Replies Last reply
    0
    • H H is here

      Hello Could some of you, great people, please help me? I have a array of controls and I would like to get the events. Here is the code: Dim pic(10) as system.windows.forms.picturebox For a=0 to 10 pic(a)=new system.windows.forms.picturebox ' the rest of the properties me.panel1.controls.add(pic(a)) next How can I catch the events of the 'pic' controls? Thanks

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You have to write up the events of the PictureBox controls yourself using AddHandler[^].

      Dim myPicBox As New PictureBox
      AddHandler myPicBox.Click, AddressOf PicBoxClick
      .
      .
      .
      Private Sub PicBoxClick(ByVal sender As Object, ByVal e As System.EventArgs)
      ...
      End Sub

      Don't forget to use RemoveHandler to disconnect the handler before you destroy the picturebox. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      1 Reply Last reply
      0
      • H H is here

        Hello Could some of you, great people, please help me? I have a array of controls and I would like to get the events. Here is the code: Dim pic(10) as system.windows.forms.picturebox For a=0 to 10 pic(a)=new system.windows.forms.picturebox ' the rest of the properties me.panel1.controls.add(pic(a)) next How can I catch the events of the 'pic' controls? Thanks

        J Offline
        J Offline
        JUNEYT
        wrote on last edited by
        #3

        You have used an array for the picture boxes which I don't suggest you to do that because you must have Addhandler or Eventhandler statements to control the event's of picture boxes. According to your code, you should have one mutual eventhandler procedure which will run all the picture boxes. Focus on Addhandler and Eventhandler statements to get more information. Here is an example from MSDN : Sub TestEvents() Dim Obj As New Class1 ' Associate an event handler with an event. AddHandler Obj.Ev_Event, AddressOf EventHandler ' Call the method to raise the event. Obj.CauseSomeEvent() ' Stop handling events. RemoveHandler Obj.Ev_Event, AddressOf EventHandler ' This event will not be handled. Obj.CauseSomeEvent() End Sub Sub EventHandler() ' Handle the event. MsgBox("EventHandler caught event.") End Sub Public Class Class1 ' Declare an event. Public Event Ev_Event() Sub CauseSomeEvent() ' Raise an event. RaiseEvent Ev_Event() End Sub End Class :))

        1 Reply Last reply
        0
        • H H is here

          Hello Could some of you, great people, please help me? I have a array of controls and I would like to get the events. Here is the code: Dim pic(10) as system.windows.forms.picturebox For a=0 to 10 pic(a)=new system.windows.forms.picturebox ' the rest of the properties me.panel1.controls.add(pic(a)) next How can I catch the events of the 'pic' controls? Thanks

          H Offline
          H Offline
          H is here
          wrote on last edited by
          #4

          Thanks It worked fine!!!!:laugh:

          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