How to set Selected Value for combox box?

Jun 16, 2010 at 5:14 AM

Hi,

 

I have a combo box named cbSex with 3 values: Unknown, Male, Female? How to set value Male for cbSex? Please help

 

Jun 18, 2010 at 4:51 AM

Hi,

I use the below code to set Selected Value = "Male" for Combo box comboBoxSex

ComboBox comboBoxSex = mainWindow.Get<ComboBox>("comboBoxSex");
comboBoxSex.Focus();            
White.Core.InputDevices.AttachedKeyboard keyboard = mainWindow.Keyboard;
keyboard.Enter("Male");

 

This code works with the combo box having data bind in xaml file(our developer hard-code)

However, with the combo box having the data binding in code-behind(cs)file this code does not work. I could not set selected Value correctly or get SelectedItemText after setting the SelectedValue for that combo. It always returns the selectedItemText=string.empty

Please consult me on this