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
455
Combo value not saving when setting the selected row
posted

I have a combo box filled with data the user clicks a button and a form is displayed that allows them to select a record that exists in the combo by looking at a lot more data to make there selection. I pass back the ID which is set to the ValueMeber of the combo. On the return I loop through the combo rows until I find the matching ID and I then set the selected row to the row object. All this works fine. My problem is that when I try to save my data the ValueMember isn't being saved.

I'm using VS2005 and I have the combo bound to a binding source, and all this is set correctly because if I make the selection by either keying in the value or selecting it in the dropdown everything works as it should. The only problem I am having is figuring out why the value isn't saving when I set the selected row in code.

Here is how I am setting the selected row.

foreach (Infragistics.Win.UltraWinGrid.UltraGridRow comboRow in icboContact.Rows){if ((Int32)comboRow.Cells["contact_id"].Value == someID){

icboContact.SelectedRow = comboRow;

break;}}

I don't understand why this isn't working. I know this has to be something with the combo not firing an edit event or something of that nature since I'm setting this in code, because if I make a selection in the combo in the normal way then the valueMember is saved correctly.

What am I missing? Thanks for any help.

Kris

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Kris,

        What property of the combo are you binding? If it's the Value property, then make sure ValueChanged is firing when you set the SelectedRow. I'm not sure it does or that it should. What you mean need to do is set the Value of the control, rather than setting SelectedRow. 

         If ValueChanged is firing when you set SelectedRow, or if it fires when you set the Value and that still doesn't help, then my guess is that it's the BindingManager that is not responding. I'm pretty sure the DotNet BindingManager makes the assumption that the developer only want it to respond to user input and not code and that it specifically checks to make sure a control has focus when it's bound property changes. This has been my experience, anyway. You might want to test this with the MS ComboBox control and see if you get the same results. 

        If that's the case, then you will need to set the value in the data source instead of (or possibly in addition to) setting it through the UI.  

     

Reply Children
No Data