Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3166
UltraComboEditor Binding Value and DataSource (BindingList)
posted

Using UltraComboEditor,

  1. Binding 'Value' to the property Model property
  2. DataSource to BindingList<string>
  3. DropDownStyle = Infragistics.Win.DropDownStyle.DropDownList

Initial state

  1. Initially the list is empty 
  2. But the Model.Property is set to valid text. However since the list is empty the UltraComboEditor.Value is not set (DropDownList)

Transition state,

  1. The list is populated with items including the item representing the Model.Property

Expecting

  1. The UltraComboEditor.Value to set to Model.Property.... but this is not happening

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;
        }
    }

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    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.

Children
No Data