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
195
Odd behavior from combo box
posted

Hello,

 I'm having a strage problem with the UltraCombo control.

 I have 5 combo boxes on a form. The content of each combo depends in some way on the value selected in the combo before it. I have implemented the RowSelected event of each combo to call a method which then fills the next combo with the appropriate values. In this method I always want to select the first item in the newly populated list of values such the events will daisy chain and the combos will fill one after another with valid choices.

 When this happens, I am having a problem where after I've set the datasource of the combo to the new source, the old values are still in list for a short time. When I then select the first row, the selection is invalid according to some business rules. If I let the program run normally the business rules engine throws an exception and halts execution. However, if I run in debug mode and slowly step thru the code I can see the values in the combo are updated by the time I get to the point when I select the first row and the program runs as expected.

 It seems that there is some asyncronous loading going on behind the scenes on the control. How can I ensure the data in the control is up to date when I select the row?? The code causing the error is below.

/// <summary>
/// Show the available account details on the UI
/// </summary>
private void ShowAccountDetails() {
    // get details
    UltraDataSource S = ToDataSource(Strategy.GetDetails(Account));
    // set members
    AccountDetailMenu.ValueMember = "DetailCode";
    AccountDetailMenu.DisplayMember = "DetailDescription";
    // bind
    if(S == null) {
        SetEmptyMenuContent(AccountDetailMenu, "No Account Details Available", "XXX");
    }
    else {
        AccountDetailMenu.DataSource = S;               
    }          
    // select the first item
    if(AccountDetailMenu.Rows.Count > 0) {
        AccountDetailMenu.Rows[0].Selected = true;  <---- this is where i can see the values aren't the same as the data source "S"
    }
}