473,396 Members | 1,923 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,396 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 1125
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.