Question

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?

Était-ce utile?

La solution

You can use Control.Tag property for this.

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top