views:

84

answers:

1
public static Hashtable m_results = new Hashtable();
private BindingSource m_bindResults = new BindingSource();

// in static constructor
m_results.Add(MyResultTypes.Failed, "Failed");
m_results.Add(MyResultTypes.Pending, "Is Pending");
m_results.Add(MyResultTypes.Completed, "Was Completed");
m_results.Add(MyResultTypes.Cancel, "Cancel it");
m_defaultResult = MyResultTypes.Pending;

// in instance constructor
m_bindResults.DataSource = m_results;
comboResult.DataSource = m_bindResults;
comboResult.ValueMember = "Key";
comboResult.DisplayMember = "Value";
comboResult.SelectedValue = m_defaultTimeoutResult;

Above code diesn't work :) It use to use strings for keys in hashtable instead of enum MyResultTypes, and it was working. What happens now is the combo box gets filled with values of a hashtable (as I want), but the default selected value isn't being selected.

How can I use enums in this example? thanks

Edit: Sorry, ComboTOResult was comboResult, missed it

Edit 2: Sorry, it does work. My bad

+2  A: 

Works for me when I change the last line to

comboResult.SelectedValue = m_defaultResult; 

ComboTOResult maybe a different box?

Mike
Sorry, ComboTOResult was comboResult. Missed it when posting, but still doesn't work for me :-/ Looking at ti again.....
flamey
You are right. I had another piece of code in Show() left from when it was strings. Thanks!
flamey