In the past, the control. findcontrol (string) method has been used in webform to obtain a control on the page. However, the controlcollection in winform does not provide the findcontrol method:
Http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformscontrolcontrolcollectionmemberstopic.asp? Frame = true
No way, you have to create a hash table.
// Populate data
Ushort [] Mydata = New Ushort [] { 111 , 222 , 333 , 444 , 555 , 666 , 777 , 888 , 999 , 1000 } ;
// Create a hashtable reference to all the textboxes
Hashtable httextbox = New Hashtable ();
Foreach (Control C In This . Controls)
{
If (C. GetType (). tostring () = " System. Windows. Forms. textbox " )
Httextbox. Add (C. Name, C );
}
// Search textbox from hashtable and evalute it.
For ( Int I = 0 ; I < 10 ; I ++ )
{
Textbox T;
T = (Textbox) httextbox [ " Textbox " + (I + 1 ). Tostring ()];
T. Text = Mydata [I]. tostring ();
}
I checked the. NET Framework 2.0 document and found that. NET 2.0 added the find Method to the control. controlcollection object...
Http://msdn2.microsoft.com/library/1hb809fy.aspx
This post is provided as "the status quo" without any guarantee and has not been granted any rights