how to know the location of a button in a button array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kristu
    New Member
    • Jan 2010
    • 2

    how to know the location of a button in a button array

    Hi

    i have a button array of [8,8]. know i want that when i press a button, i get the location of the button in the array, not which button is pressed but the location.I used the sender to do a tempbutton and therefore change the text of that particular button but i want its location....

    (the array is buttarr[8,8])

    ex: buttarr[1,2] was pressed

    can someone help

    Thanks
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    There's a few things you can do... first, the hard way!

    When you click the button, search the array for it. The event handler for the button has a parameter called sender, this is the object that triggered the event. Cast it as a button and then look for it in the array. When you find it, you'll have the index location of the button.

    Now for the easy way. When you build the button grid, do one of two things. Name the button (Button.Name) something appropriate to it's grid location. You could also put that into the tag (Button.Tag). That way, your sender would already know where it was in the grid, you wouldn't need to search for it.

    Comment

    Working...