1
Answer

Updating combobox if the ToString() result of an item changes

Ask a question
Valter

Valter

14y
3.2k
1
Hello,
I've got a simple question related to combobox. Consider that a combobox is populated with the instances of the following example class:
class Plot
{
private string label;

public string Label
{
get { return label; }
set { label = value; }
}

public override string ToString()
{
return label;
}
}

Now consider that one of these objects will be assigned a different label somewhere else in the program. How can I notify the combobox that it should call the ToString() method of this item again to update its list accordingly? I hope there exists some intelligent mechanism, I'd like to avoid just manually repopulating the combobox each time an item label is changed.

Answers (1)