3 Replies - 2914 Views - Last Post: 31 March 2010 - 03:31 AM Rate Topic: -----

#1 turok   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-March 10

System.Windows.Forms.Control.Tag

Posted 30 March 2010 - 05:54 AM

Could someone detail about what "System.Windows.Forms.Control.Tag" is & what it does?? All I could find out from MSDN & elsewhere is that it is related to controls(maybe is a property of controls) such as textbox & stores some data about an object. What data exactly it stores & how can we access it?
Thanx!!!
Is This A Good Question/Topic? 0
  • +

Replies To: System.Windows.Forms.Control.Tag

#2 n8wxs   User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: System.Windows.Forms.Control.Tag

Posted 30 March 2010 - 06:13 AM

See Control.Tag Property
Was This Post Helpful? 1
  • +
  • -

#3 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: System.Windows.Forms.Control.Tag

Posted 30 March 2010 - 06:14 AM

It's just an object that lets you store data about the control. It's null by default, and can be accessed like this:

// Store text.
button.Tag = "Some data.";

// ...or...

// Store another button. 
// In real life there would be no reason to do this.
button.Tag = new Button();



The Tag property is of type object. Since all classes derive from object, the Tag property can store most types.
Was This Post Helpful? 0
  • +
  • -

#4 batesy3k   User is offline

  • D.I.C Regular

Reputation: 41
  • View blog
  • Posts: 299
  • Joined: 10-September 09

Re: System.Windows.Forms.Control.Tag

Posted 31 March 2010 - 03:31 AM

Another example you could use the tag for is say to hold a default value for a textbox, then say you had a revert button, it could read that value from the Tag back to the textbox...
txtUsername.Tag = "batesy3k";

btnRevert_Click(object sender, EventArgs e)
{
    txtUsername.Text = txtUsername.Tag;
}



Untested, but should give you an example
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1