Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

:confused:

 

Im having trouble again.

Imagine a minefield grid. You have the tab index of the sender.

how can I access the tag property of the adjoining buttons without clicking on them? I would like to use the tab index property of the button.

 

I was thinking of scrolling through all 100 buttons untill the tabindex matched the index I am interested in, then read the tag, but I don't know how to increment the button names: btn1,btn2, etc.

 

My brain hurts,

Dave

Guest mutant
Posted

You could go through every button there and find the one with the matching index.

       Dim ctrl As Control
       For Each ctrl In Me.Controls
           If TypeOf ctrl Is Button Then
               if ctrl.TabIndex = numberyouwant then
                   'do something to that button
               end if 
           End If
       Next

Guest mutant
Posted

Or a simpler way of which i didn't think when writing my first post :D

Before the code checked every control if its button. Now you it will only go through buttons. (So it should be better :) )

       Dim btn As Button
       For Each btn In Me.Controls
           If btn.TabIndex = numberyouwant Then
               'do something to the button
           End If
       Next

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...