When I add an item to the CheckedListBox list, I also want to keep the link to another object. I tried adding a new instance of this object to the CheckedListBox.
public class CheckedListBoxExtention : CheckedListBox { private ReferenceItem _referenceItem; public ReferenceItem storedItem { get { return _referenceItem; } set { _referenceItem = value; } } public CheckedListBoxExtention(ReferenceItem storedItem) { _referenceItem = storedItem; } }
This works in that later, when I predict, although the elements in the CheckedListBox I have a reference to the _referenceItem object. However, when I add such items, the CheckedListBox appears empty (list in the GUI itself). So I'm trying to find a way to redefine the text of an element or something like that.
This is the code I used to fix the problem.
class ReferenceItemWrapper { private ReferenceItem _item; public ReferenceItemWrapper(ReferenceItem item) { _item = item; } public ReferenceItem getItem {get {return _item;}} public override string ToString() { return _item.ToString(); } }
I'm a little new to wrappers. Why did it work after it was wrapped, when it did not work, when I added the ReferenceItem directly to the CheckedListBox?
source share