You can loop through the Controls list for the form, and check "is this a button"?
For Each c As Control In Controls
Dim b As Button = TryCast(c, Button)
If b IsNot Nothing Then
....
End If
Next
"sorry i am not understand
For Each c As Control In Controls
Dim b As Button = TryCast(c, Button)
If b IsNot Nothing Then
For tt 1 to 50
mybutton.Name = "Button"&tt
With mybutton
.Text = "test"
.ForeColor = Color.Blue
End With
next
End If
Next
in this way will beDid he??
or
AddHandler Button1.Click, AddressOf secilenbuton
AddHandler Button2.Click, AddressOf secilenbuton
AddHandler Button3.Click, AddressOf secilenbuton
AddHandler Button4.Click, AddressOf secilenbuton
.
.
.
.
.
AddHandler Button50.Click, AddressOf secilenbuton
presentation, I ask,
How can I write the following definition as a short"
No, when you do the
For Each
loop, every time you get a value of "b" that is not Nothing, it it already a button.
You do not need the "For tt" loop any more.
For Each c As Control In Controls
Dim b As Button = TryCast(c, Button)
If b IsNot Nothing Then
With b
.Text = "test"
.ForeColor = Color.Blue
End With
End If
Next