Results 1 to 3 of 3

Thread: Help with one handler for an array of labels.

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    6

    Help with one handler for an array of labels.

    I have a 2 dimensional array of labels that are created at runtime and I do not know how many labels will be created before running the program. How do I make one handler to change the background color of the label clicked.
    I already have for each label when created:

    AddHandler Labels(j, i).Click, AddressOf Labels_Click

    But in the handler how do I change the background color of the label that was clicked?

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Help with one handler for an array of labels.

    try this
    vb Code:
    1. Private Sub Labels_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    2.         Dim lb As Label = DirectCast(sender, Label)
    3.         lb.BackColor = Color.Red
    4.     End Sub



  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    6

    Re: Help with one handler for an array of labels.

    Ah, it worked. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width