Vra

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?

Was dit nuttig?

Oplossing

You can use Control.Tag property for this.

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

Ander wenke

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.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top