Suppose I have a window-shaped label control called "UserName". How can I refer to this tag programmatically using the tag name?
For example, I can do:
For each ctrl as Control in TabPage.Controls
If ctrl.Name = "UserName" Then
' Do something
End If
Next
It seems rather inefficient. I would like to do something like:
TabPage.Controls("UserName").Text = "Something"
I did some searches, but could not find a satisfactory answer. Most suggested loops, some say that .NET 2005 does not support direct recovery using a string name, and the FindControl method was only asp.net ...
EDIT
Thanks for the answer. Here are a few details.
I have a window shape with three tabs, all of which are very similar in design and function, that is, drop-down menus, shortcuts, react equally to events, etc.
, , , .. .
, "RecordCounter" , datagridview, .
, , , datagridview , ( "RecordCounter" ,).
, , "RecordCounter" , .
ActivePage TabPage, , , - :
ActivePage.RecordCounter.Text = GetNumberOfRows()