G
Guest
I have a ListBox built of a simple custom object for the
ListItems used to be able to hold a Data Value, and a
Display Value, with accessors for each. I have
overridden the ToString method to display the Display
value.
(Two examples that I have seen, including an MS example,
suggest that the DisplayMember and ValueMember properties
of the ListBox can be used in this way, I could not get
it to work using the ListItems.Add method - overriding
toString() seems to be the only way. Setting Datasource
may be a different story.)
When I update the Display value of the underlying object,
the associated ListBox entry does not update, nor have
any of my attempts to refresh the list worked.
Ex:
((CustomObject) lstControl.SelectedItem).Display = "New
Display Value"
The underlying object updates properly. But the ListBox
continues to show "OLD Display Value" in the control!
How do I get it to call the ToString() method again for
that item? Someone has already suggested that I remove
and then re-add the item, but I do not want to do this if
I can avoid it - there must be a way to get the ListBox
to refresh. Help!
ListItems used to be able to hold a Data Value, and a
Display Value, with accessors for each. I have
overridden the ToString method to display the Display
value.
(Two examples that I have seen, including an MS example,
suggest that the DisplayMember and ValueMember properties
of the ListBox can be used in this way, I could not get
it to work using the ListItems.Add method - overriding
toString() seems to be the only way. Setting Datasource
may be a different story.)
When I update the Display value of the underlying object,
the associated ListBox entry does not update, nor have
any of my attempts to refresh the list worked.
Ex:
((CustomObject) lstControl.SelectedItem).Display = "New
Display Value"
The underlying object updates properly. But the ListBox
continues to show "OLD Display Value" in the control!
How do I get it to call the ToString() method again for
that item? Someone has already suggested that I remove
and then re-add the item, but I do not want to do this if
I can avoid it - there must be a way to get the ListBox
to refresh. Help!