Introduction
Not a lot of people realize how powerful the Tag
property actually is... (For people coming from other languages like Delphi where the Tag
property is a String
, using the Tag
as an Object opens lots of opportunities.)
I will give you a quick overview and show you how you can use it.
Using the code
The Tag
property is of type Object
, making it a very powerful to work with. An Object
is like the seed of OO.
Here is an example of how you can use it:
First, you will need to create a class with all the details you want to save.
public class Person
{
public string Name;
public string Surname;
}
Then, you populate it and link it to any Tag
property. As easy as that:
Person TempPerson = new Person();
TempPerson.Name = "Jack";
TempPerson.Surname = "The-Man!!!";
this.Tag = TempPerson;
this.Text =
((Person)this.Tag).Name +
" " +
((Person)this.Tag).Surname;
With the above code, I use the the Form
(this
) and link an object of any kind to the Tag
property. Very handy!!!
In your day to day apps, you can use this to save limitless data on any Tag
property (create a Node Index for example, and or link all the info you may need to a Tree Node.)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.