Using UltraComboEditor,
Initial state
Transition state,
Expecting
public partial class DataBindingUltraComboEditorForm : Form { private readonly Model m_model; private readonly BindingList<string> m_bindingList; public DataBindingUltraComboEditorForm() { InitializeComponent(); //Restricting to items in the list ultraComboEditor1.DropDownStyle = Infragistics.Win.DropDownStyle.DropDownList; m_model = new Model { BindProperty = "One" }; ultraComboEditor1.DataBindings.Add("Value", m_model, "BindProperty", false, DataSourceUpdateMode.OnPropertyChanged); m_bindingList = new BindingList<string>(); ultraComboEditor1.DataSource = m_bindingList; } private void OnButtonClick(object sender, EventArgs e) { m_bindingList.Add("Three"); m_bindingList.Add("Two"); m_bindingList.Add("One"); //NOTE: With following lines commented "One" is not set as Value of ultraComboEditor1 //ultraComboEditor1.DataBindings.Clear(); //ultraComboEditor1.DataBindings.Add("Value", m_model, "BindProperty", false, DataSourceUpdateMode.OnPropertyChanged); //TODO: How to trigger UltraComboEditor to refresh Value } private class Model : INotifyPropertyChanged { private string m_bindProperty; public string BindProperty { get { return m_bindProperty; } set { m_bindProperty = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("BindProperty")); } } public event PropertyChangedEventHandler PropertyChanged; } }
Hi,
What you are doing here will not work. In DropDownList style, the combo's Value property will not accept a value that is not on the list. You need to make sure the list is bound first, before you bind the Value property on the control and that the list contains the value you are binding to.