Hello,
I am trying to add 3 of my own objects to a combobox. I can see that 3 items were added, but I cannot see any string or description, only 3 whitespaces.
I have made an interface that implements (among other things) the function ToString(). All my objects are implementing this interface.
When I am debugging through my code and I am checking the result of i1.ToString(), it gives me the proper result...
I could just add the string to the combobox, but I want to use these objects later on in my program.
Obviously I would like to see some text in my combobox. What am I doing wrong?
Greetz
Mim
I am trying to add 3 of my own objects to a combobox. I can see that 3 items were added, but I cannot see any string or description, only 3 whitespaces.
I have made an interface that implements (among other things) the function ToString(). All my objects are implementing this interface.
Code:
//here I want to populate my combobox
IMyInterface i1= new MyClass1();
cmbMyCombo.Items.Add(i1);
IMyInterface i2= new MyClass2()
cmbMyCombo.Items.Add(i2);
IMyInterface i3 = new MyClass3();
cmbMyCombo.Items.Add(i3);
//--------------------
public interface IMyInterface
{
string ToString();
//...
}
class MyObject1: IMyInterface, System.Data.DataTable
{
public override string ToString()
{
return "some string";
}
//...
}
When I am debugging through my code and I am checking the result of i1.ToString(), it gives me the proper result...
I could just add the string to the combobox, but I want to use these objects later on in my program.
Obviously I would like to see some text in my combobox. What am I doing wrong?
Greetz
Mim