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