Pregunta

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?

¿Fue útil?

Solución

You can use Control.Tag property for this.

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

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top