To do the latter you need to define a class which defines methods for getting the value (IE) and the representation (International Electromatics) of its instances. Then you set the DataSource of the control to be an ArrayList of these objects. Finally you set the DisplayMember and ValueMember properties of the control to the names of the the class methods.
Now, the control's SelectedValue property will be the ValueMember of the object that is currently selected. NB that SelectedValue appears to return an object which you must cast to a string, not a string per se.
Fragmentary example:
ArrayList Availabletests = new ArrayList();
...
Availabletests.Add( new UnitTest( 1, "tryparse datetime(p)" ) );
Tests.DataSource = Availabletests;
Tests.DisplayMember = "Representation";
Tests.ValueMember = "Value";
...
Output.Text = Tests.SelectedValue.ToString();
...
public class UnitTest {
/*protected*/ private int number;
/*protected*/ private string description;
public UnitTest (int num, string desc) {
this.number = num;
this.description = desc;
}
public string Value {
get { return number.ToString(); }
}
public string Representation {
get { return number.ToString() + ": " + description; }
}
}
Properly explained example with US states in ListControl.DataSource
As always with .NET there's a lot of typing but I admit this is a nice flexible, modular way to go about it.