I have a Struct that looks like this:
public struct Server
{
public String ServerName, ServerUrl, ServerEnvironment;
};
Then I create a List of Structs:
List<Server> MyServers = new List<Server>();
...and read about eight records into it from a small XML file. This is working well, and if I hover over "MyServers" in the debugger, it looks something like this:
MyServers Count=8
[0] {MyApp.Server}
ServerEnvironment "DEV"
ServerName "My Dev Server #1"
ServerUrl "https://mydev1.mycompany.com/"
[1] {MyApp.Server}
etc...
Then if I do something like MessageBox.Show(MyServers[0].ServerName);, it displays the expected value.
Now what I would like to do is create a ComboBox from the ServerName fields. When the user selects one, I think I would then use the SelectedIndex property of the ComboBox to access the other information (ServerUrl and ServerEnvironment) for the selected ServerName.
I thought I could do something like this:
comboBoxServers.DataSource = MyServers ... something ... ServerName;
But I can't seem to find anything that works. Is this even possible, or do I need to create a separate, simple List with only the ServerName strings and use that for the ComboBox DataSource?