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

前端 未结 6 504
情话喂你
情话喂你 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:50

    Unless I'm misunderstanding the question context, I think you're making it too difficult. in code, you just use thelabel name as your reference as in:

    UserName.Text = "Something"
    

    Is there something you're trying to accomplish that makes that not right?

提交回复
热议问题