How Do You Add Event Handler to 50 button array????

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jimmy-X via DotNetMonster.com

    How Do You Add Event Handler to 50 button array????

    Hello, I've created an array of fifty buttons and want to tie their click
    events together. Can anyone help me? Here's the code that I'm using to create
    the controls. I just don't know how to tie their events
    together.

    For Each Ctrl As Control In Form1.Controls
    If TypeOf Ctrl Is Panel And Microsoft.Visua lBasic.Left(Ctr l.Name,
    9) = "PanelName" Then
    PanelName(Val(M icrosoft.Visual Basic.Right(Ctr l.Name, 2))) =
    Ctrl
    End If
    Next

    Thanks,
    Jimmy

    --
    Message posted via http://www.dotnetmonster.com

  • Armin Zingler

    #2
    Re: How Do You Add Event Handler to 50 button array????

    "Jimmy-X via DotNetMonster.c om" <u42910@uweschr ieb
    Hello, I've created an array of fifty buttons and want to tie their
    click events together. Can anyone help me? Here's the code that I'm
    using to create the controls. I just don't know how to tie their
    events
    together.
    >
    For Each Ctrl As Control In Form1.Controls
    If TypeOf Ctrl Is Panel And
    Microsoft.Visua lBasic.Left(Ctr l.Name, 9) = "PanelName" Then
    PanelName(Val(M icrosoft.Visual Basic.Right(Ctr l.Name,
    2))) = Ctrl
    End If
    Next
    Inside the loop:
    AddHandler ctrl.Click, AddressOf OnPanelClick

    Event handler:
    Private Sub OnPanelClick( _
    ByVal sender As Object, ByVal e As System.EventArg s)

    End Sub


    Armin

    Comment

    Working...