Home All Groups Group Topic Archive Search About
Author
28 Apr 2006 8:12 PM
c_shah
Can someone please explain to me the purpose of the tag property for
WindowsForm controls such as a TEXTBOX? What is the benefit of using
this
property if any?

Author
28 Apr 2006 8:15 PM
Chris Dunaway
It's just a convenient holding place to store some bit of data or
object that you want to associate with the control.
Author
28 Apr 2006 8:16 PM
zacks
The Tag property is datatype of Object, which means it can be any
datatype. It's purpose is to allow you to store some information that
is related to the control it is a property of, and since it is an
Object, this information can be of any form, a boolean, a string, a
collection of anything, etc.
Author
28 Apr 2006 11:31 PM
Martin Milan
za***@construction-imaging.com wrote in
news:1146255399.347493.21060@e56g2000cwe.googlegroups.com:

> The Tag property is datatype of Object, which means it can be any
> datatype. It's purpose is to allow you to store some information that
> is related to the control it is a property of, and since it is an
> Object, this information can be of any form, a boolean, a string, a
> collection of anything, etc.

I'm only just starting to read up on vb.net and c# - work is a vb6
shop...

I was under the impression that dotnet controls didn't support the tag
property - I take either I was wrong, or this has changed?

Am I really able to use a value type in an object property? I wasn't
aware that dotnet supported autoboxing either...

Martin.
Author
30 Apr 2006 12:29 AM
Jay B. Harlow [MVP - Outlook]
Martin,
| I was under the impression that dotnet controls didn't support the tag
| property - I take either I was wrong, or this has changed?
..NET Windows Forms have supported the Tag property on Control since version
1.0

| Am I really able to use a value type in an object property? I wasn't
| aware that dotnet supported autoboxing either...

Yes, .NET has always supported autoboxing. However you need to use CType or
DirectCast to "unbox" if you are using Option Strict On.


--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


Show quoteHide quote
"Martin Milan" <I***@m.i.do> wrote in message
news:Xns97B456447823I8spmido@194.117.143.53...
| za***@construction-imaging.com wrote in
| news:1146255399.347493.21060@e56g2000cwe.googlegroups.com:
|
| > The Tag property is datatype of Object, which means it can be any
| > datatype. It's purpose is to allow you to store some information that
| > is related to the control it is a property of, and since it is an
| > Object, this information can be of any form, a boolean, a string, a
| > collection of anything, etc.
|
| I'm only just starting to read up on vb.net and c# - work is a vb6
| shop...
|
| I was under the impression that dotnet controls didn't support the tag
| property - I take either I was wrong, or this has changed?
|
| Am I really able to use a value type in an object property? I wasn't
| aware that dotnet supported autoboxing either...
|
| Martin.
Author
4 May 2006 2:49 AM
Eric Moreau
> I was under the impression that dotnet controls didn't support the tag
> property - I take either I was wrong, or this has changed?

The first beta of .Net 2002 didn't have it but programmers required it.

--


HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://emoreau.s2i.com/
Author
28 Apr 2006 8:18 PM
Marina Levit [MVP]
It's there so you can associate arbitrary data with the control. Then,
whenever you need that piece of information, you can just get the object
from the Tag property and examine it.

Show quoteHide quote
"c_shah" <shah.chi***@netzero.net> wrote in message
news:1146255139.047164.30780@y43g2000cwc.googlegroups.com...
> Can someone please explain to me the purpose of the tag property for
> WindowsForm controls such as a TEXTBOX? What is the benefit of using
> this
> property if any?
>
Author
28 Apr 2006 10:20 PM
Herfried K. Wagner [MVP]
"c_shah" <shah.chi***@netzero.net> schrieb:
> Can someone please explain to me the purpose of the tag property for
> WindowsForm controls such as a TEXTBOX? What is the benefit of using
> this
> property if any?

Check out the documentation for 'Control.Tag', which mentions some use
cases.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>