I've recently started trying to learn windows forms and C# at the same time. I've found myself in a rut where i just seem to be blanking out while i'm searching the documentation and have probably gone down a rabbit hole on a very simple problem.
I'm trying to create a combobox (DropDown style) and populate it with items. My understanding is that if you want the ComboBox to have both displayed items and values that are different, you have to create an object to represent this and pass that into the Items.Add method. Also, based what I've read in the docs, if you just pass a string object the ComboBox will use the same string for the DisplayMember and the ValueMember. So I'm doing this:
string string_value = "Foo";
When I execute the application and look at the combobox i can expand it but it only contains blank entries for each item that i have added. However, if I select one of the blank lines, the expected 'Foo' string will show up in the textbox.
I have also tried writing an object with the DisplayMember/ValueMember properties, instantiating the object, setting these two properties and passing that to Items.Add but this results in the same behaviour.
Am I doing something wrong? Could someone post a complete example of populating a dropdown combobox with an arbitrary string/value pair?