I have an array of controls (made at runtime) and containing 10 buttons
(Button(0),Button(1)....etc.).
Ho I can get the index of a selected control?
For example if I click the button number 5 how I can retrieve its index
(that it is the fifth button)?
(In VB6 there was the "INDEX" .....)
Thanks
Massimo
In your click handler:
Dim b as Button = CType(sender, Button)
dim idx as integer = Array.IndexOf(Button, b)
--
Mike
Bob
"Massimo Riccardi" <rima...@aliceposta.it> wrote in message
news:4b2e2e6d$0$1106$4faf...@reader3.news.tin.it...
> I have an array of controls (made at runtime) and containing 10 buttons
> (Button(0),Button(1)....etc.).
> How I can get the index of a selected control?
Why do you need it?
Event handlers all receive a reference to the Control that raised the
event, so you don't need to index for that ...
Private Sub AnyButton_Click( _
byval sender as Object _
, byval e as EventArgs _
)
Dim btn as Button = Nothing
If TypeOf sender is Button Then
btn = DirectCast( sender, button )
End If
btn.Text = ...
End Sub
HTH,
Phill W.