473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Understanding the TAG property

Can someone please explain to me the purpose of the tag property for
WindowsForm objects such as a TEXTBOX? What is the benefit of using this
property if any? Thanks, a bunch.
--
TC
Sep 18 '05 #1
3 1124
Terance,

Think about the fact that you have to loop through some controls and want
only those you have marked with "a" (it can even be a class object with more
parameters). Than by instance this Tag is really extremely useful

I hope this helps,

Cor
Sep 18 '05 #2
Cor:

Can I use a tag on a object and reference that object in a User Control
(e.g. ucmdAdd Button)? and if so, how do I go about doing this? I'm using
VB.net.
--
TC
"Cor Ligthert [MVP]" wrote:
Terance,

Think about the fact that you have to loop through some controls and want
only those you have marked with "a" (it can even be a class object with more
parameters). Than by instance this Tag is really extremely useful

I hope this helps,

Cor

Sep 18 '05 #3
Hi Terrance,

The Tag property is provided so you can associate a Control with some kind of information. The information can be anything you like. As Cor said, you could mark Controls and filter the controls in a loop by the information in the Tag property.

Another example:

Consider a bunch of Labels with animal names. You want the user to put animals inside animal pens by dragging from the Labels, but not dragging the Labels themselves. The information in the animal pens is more complex than plain text, so you need some kind of Animal object.

One solution could be to drag the Label text into the pen an use code to determine which Animal to create and put in it. Another way could be to create all Animals in advance and store the references to these objects inside the Tag properties of the appropriate label. Then, instead of dragging the Label text, you drag the Animal object and put it directly inside the pen.
--
Happy coding!
Morten Wennevik [C# MVP]
Sep 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I'm trying to gain a better understanding of javascript by studying examples. I noticed this in an online tutorial. I don't get the use of "this". >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You might want...
5
by: Just Me | last post by:
I have a UserControl that contains a few controls on it. If when one of the buttons is clicked I want to, in the click event, set the cursor to Cursor = Cursors.WaitCursor I want the cursor...
3
by: Terrance | last post by:
Can someone please explain to me the purpose of the tag property for WindowsForm objects such as a TEXTBOX? What is the benefit of using this property if any? Thanks, a bunch. -- TC
3
by: SlimFlem | last post by:
I am new to the WebPartManager stuff and am still learning how to set this up properly. I am creating instances of WebPart classes from loaded DLLs and add them to the Page's WebPartManager. If I...
3
by: Chris Peeters | last post by:
Hi, I have a Listbox with 3 strings added at design time : "Red" "Green" "Blue". I add a fourth string at run-time in Page_Load: protected void Page_Load(object sender, EventArgs e) { if...
2
by: VJ | last post by:
I tried to write sample code to get understanding of javascript's prototypal inheritance (along with the variety of function calling choices.. ) During the process, I got myself throughly...
1
by: moondaddy | last post by:
I have a group of elements inside a grid and want to align them along the left side of the grid. I also want have this group centered vertically and the xaml below demonstrates the appearance want...
3
by: Sarah | last post by:
Hi - Please be gentle. I am quite new to visual basic, but I have been going through tutorials and reading up. I found a code snippet on the internet that I wanted to see if I could re-purpose...
2
Dormilich
by: Dormilich | last post by:
Hi, I'm testing my classes for a web page and I stumble upon an error I don't have a clue what it means: Error: Fatal error: Can't use method return value in write context in "output.php" on...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.