문제

I need to add a secondary Id or even some custom text to controls like Button, Textbox, ListBox etc., so that i can later use it for programmatic purposes and should not be displayed to user.

I can do this in ASP.net using Attributes property for almost any control, but when I checked with windows forms I found it doesn’t have this property, can I find any other alternatives in windows forms?

도움이 되었습니까?

해결책

You can use Control.Tag property for this.

myButton.Tag = whatever;
myTextBox.Tag = whatever;
...

다른 팁

Use the Control.Tag property. Source: MSDN

"A common use for the Tag property is to store data that is closely associated with the control."

This sounds like what you're after.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top