Its actually not that difficult, all you have to do do is access the
ControlCollection that contains your buttons. So in the case of a Windows
Form there is a property called Controls (its a ControlCollection) and you
can access members by index (int) or key (string).
So for a quick example I created a very simple WinForm app and placed a
couple buttons on it and placed the following in the form load event
handler:
this.Controls["button1"].Text = "Test";
and sure enough the button text changed from button1 to Test on load. You
will want to cast your control to a button if you want to access button
specific properties/methods. The only reason my example works without a cast
is because Text is inherited from the Control class.
Hope that helps.
-Matt Newman
-http://www.bestsnowman.com/
"Rob" <Ro*@discussions.microsoft.comwrote in message
news:BA**********************************@microsof t.com...
Hi all,
I would like to access just one of several controls by its number:
I do not want call:
Button1.Text
instead I want to call:
Button+"1".Text
"1" will be a char or byte or something else and come from another
function.
I solved it in Delphi years ago - what about C#?
Can anybody help?