I have the following code:
public partial class Form1 : Form
{
public BindingList<Class> List = new BindingList<Class>();
public Form1()
{
InitializeComponent();
List.Add(new Class());
comboBox1.DataSource = List;
}
}
public class Class : Dictionary<string, string>
{
public override string ToString()
{
return "Class";
}
}
The problem is that the combo box shows the text “(Collection)” instead of “Class”. Whenever I remove the Dictionary<string, string> as an ancestor of Class, the code show’s “Class” as I want it to. Even when I derive it from another base class I wrote myself it works OK. This is of course not the real program but the problem isolated. So am I missing something or I don’t have a choice other than declare a Dictionary<string, string> field in Class instead of subclassing it? (Oh, and by the way, I already tried adding a breakpoint in the ToString function and it’s not being called.)
You can try this:
I have tried it and now the combobox shows the text ‘Class’ and not “(Collection)”.