Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Elegant Ribbon Tech Support » Combobox databinding Collapse All
Subject Author Date
Mikhail Shilkov Jan 30, 2010 - 5:27 AM

Hi. I tried to bind object property to combobox, but it displays wrong value. I have binded object’s property to textbox and it works.


There is code:


           cbxDocumentType.DisplayMember = "Name";

            cbxDocumentType.ValueMember = "DocTypeID";           

            cbxDocumentType.DataSource = docCatalog.LoadCatalog().ToList();

            Binding binding = new System.Windows.Forms.Binding("SelectedValue", tmcJournalLine, "DocTypeID", true, DataSourceUpdateMode.OnPropertyChanged);

            cbxDocumentType.DataBindings.Add(binding);

Technical Support Feb 2, 2010 - 10:15 AM

Please try to replace

Binding binding = new System.Windows.Forms.Binding(
   "SelectedValue", tmcJournalLine, "DocTypeID", true, DataSourceUpdateMode.OnPropertyChanged);
to
Binding binding = new System.Windows.Forms.Binding(
   "SelectedItem", tmcJournalLine, "DocTypeID", true, DataSourceUpdateMode.OnPropertyChanged);
and let us know if this helped.