tags:

views:

47

answers:

4

I see a 'Tag' property in the design view for most WinForms controls. I have never used this tag and want to know why I would want to use it.

+4  A: 

Its a general "catch-all" for additional data you wish to store with a control.

I too have never used it.

Jamiec
+2  A: 

for example you have a lot of buttons with single method handling clicks. then at handler you have do differentiate them from each other. So you put some sort of id (or reference) and then access it there.

Andrey
I like this idea.
Reena
+5  A: 

It allows you to store some of your own data with a control. It mostly useful in tree controls where you might want each node/leaf to have some extra data associated with it. This way when you click on a node you can perform an action relevant to the node.

Matt Warren
A: 

We perform heavy use of tags. We have some methods for checking input, and these methods checks whats in the tags in order to know what control to perform.

IE: if a textbox has RQ=1;DT=int;MAX=100

the automatic method knows that this text can not be left blank, that should accept only integers within 0 and 100. We have a complete seudo declarative language for this.

Kind of useful!

More specific for your question, Tags are for your use.

Daniel Dolz
Thx. I can see some good use for this: attach validation constraints to each control using tags.
Reena
The same algorithm, when it detects RQ=1, set the background color with a prederfined color. So with the same effort, your interface shows which fields are mandatory and which aren't
Daniel Dolz