Winform checkedboxlist add item and Value

Source: Internet
Author: User

Recently, I have helped my colleagues solve this problem ~ Propose the solution ~

Because when checkedboxlist. Items. Add is added, an object is added ~ So I often don't know how to add his value ~

At this time, you can upload a class ~ To implement this item, see the following example:

Public class myitem
{
String m_text = "";
String m_value = "";

Public myitem (string text)
{
M_text = text;
}
Public myitem (string text, string value)
{
M_text = text;
M_value = value;
}

Public String text
{
Get {return m_text ;}
Set {m_text = value ;}
}
Public String Value
{
Get {return m_value ;}
Set {m_value = value ;}
}

Public override string tostring ()
{
Return this. text;
}

}

This class is used as the checkedboxlist item to add ~

This class is mainly used to override tostring () This method ~ Create a text & Value Property

Add Method

Checkedlistbox1.items. Add (New myitem ("11", "AA "));
Checkedlistbox1.items. Add (New myitem ("22", "BB "));

Escape

(Myitem) checkedlistbox1.items [1]). Text

(Myitem) checkedlistbox1.items [1]). Value

 

Reference from: http://www.dotblogs.com.tw/jacky19819/archive/2009/03/25/7696.aspx

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.