How do I refer to a windows form control by name (C# / VB)

前端 未结 6 413
情话喂你
情话喂你 2020-12-21 08:21

Suppose I have a label control on a windows form called \"UserName\". How can I refer to that label programmatically using the label name?

For example I can do:

6条回答
  •  隐瞒了意图╮
    2020-12-21 08:43

    One solution would be to pass the controls to the class in addition to or instead of the tabpage. For example, you could have a RecordCounter property in addition to your ActivePage property. (Incidentally, Find is efficient to code but not so efficient at runtime.)

提交回复
热议问题