The Tag property of a C # control

Source: Internet
Author: User

Always thought that the control's Tag property is similar to the TextBox's Text property, just to save the user's markup on the control of the text information or Boolean value, so after seeing the code below, it feels a bit confused.

<span style= "FONT-SIZE:18PX;" >listviewitem item = LISTVIEWCHANNELS.ITEMS.ADD (devicename);
Item. Tag = ipcchannel;</span>

The function of the above code is to create a ListViewItem object and set its tag value to a custom class-IpcChannel object.

<span style= "FONT-SIZE:18PX;" >channellist.add (item. Tag as IpcChannel);</span>

The purpose of this code is to extract the object of the custom class IpcChannel saved in the Tag property of the item of the ListViewItem class created above and add it to the list.


Check the back before you know, the original Tag property is defined as follows:

<span style= "FONT-SIZE:18PX;" >public Object Tag {get; set;} </span>

Definition reference MSDN;
And in. NET is derived from the object class, you can set the value of any custom type object or base type for the tag property to facilitate the program to read when necessary.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.