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
1210
UltraCombo Control - Selected Item not reflecting on Drop Down Selection
posted

Hi,

I am using a Form with 2 UltraCombos  in which  second combo Value will set based on First Combo's Selected  Value

But, when I try to do this , Second Combo Value gets Updated based on First Combo's Drop down row Selection , but I am not able to Get the Selected Row to show up in the First Combo Box text Editor, (i.e., Selected row Displaymember  in the Dropdown is not  reflecting in the Editor Textbox )

I have tried using both combo.SyncWithManager with true and False, but didn't help,

Herewith, I have attached the sample also for your Understanding,

Pls advice me where I am doing wrong in the sample, But when I try to do the same with Windows ComboBox it is working fine

Awaiting your Advice ,

Thanks and Regards,

Ganesh

UltraComboSample.zip
Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi Ganesh,

    If you put a breakpoint in the cmbCountry_ValueChanged event and then run the application and select an item from the Country list, you will see that the event fires, just as it should. But if you then step through the code line by line, when you get to the line:

    cmbState.Value = 2;

    When you step past this line, the code come back into the event a second time. Looking at the call stack, it looks like this:

    >    UltraComboSample.exe!UltraComboSample.Form1.cmbCountry_ValueChanged(object sender = {Infragistics.Win.UltraWinGrid.UltraCombo}, System.EventArgs e = {System.EventArgs}) Line 51    C#
         [Native to Managed Transition]    
         [Managed to Native Transition]    
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.OnValueChanged(System.EventArgs e = {System.EventArgs}) Line 10479 + 0x11 bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.FireEvent(Infragistics.Win.UltraWinGrid.ComboEventIds id = ValueChanged, System.EventArgs e = {System.EventArgs}) Line 9964 + 0xe bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.FireValueChangedEventHelper(bool hasChanged = true, object newValue = 1) Line 12593 + 0x25 bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.SelectedItemChangeHelper(Infragistics.Win.UltraWinGrid.ComboSelectedItemChangeContext context = Value, object newData = 1) Line 12573 + 0x14 bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.Value.set(object value = 1) Line 7784 + 0x13 bytes    C#
         [Native to Managed Transition]    
         [Managed to Native Transition]    
         System.dll!System.ComponentModel.ReflectPropertyDescriptor.SetValue(object component = {Infragistics.Win.UltraWinGrid.UltraCombo}, object value = 1) + 0x124 bytes    
         System.Windows.Forms.dll!System.Windows.Forms.Binding.SetPropValue(object value) + 0xcf bytes    
         System.Windows.Forms.dll!System.Windows.Forms.Binding.PushData(bool force) + 0x7c bytes    
         System.Windows.Forms.dll!System.Windows.Forms.BindingManagerBase.PushData(out bool success = true) + 0x51 bytes    
         System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManager_PushData() + 0x4f bytes    
         System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnItemChanged(System.Windows.Forms.ItemChangedEventArgs e = {Index = 0}) + 0x5e bytes    
         System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) + 0x3d9 bytes    
         System.Windows.Forms.dll!System.Windows.Forms.BindingSource.OnListChanged(System.ComponentModel.ListChangedEventArgs e) + 0x7e bytes    
         System.Windows.Forms.dll!System.Windows.Forms.BindingSource.ListItem_PropertyChanged(object sender, System.EventArgs e) + 0x49 bytes    
         System.dll!System.ComponentModel.PropertyDescriptor.OnValueChanged(object component, System.EventArgs e) + 0x51 bytes    
         System.dll!System.ComponentModel.ReflectPropertyDescriptor.OnValueChanged(object component, System.EventArgs e) + 0x65 bytes    
         System.dll!System.ComponentModel.ReflectPropertyDescriptor.SetValue(object component = {UltraComboSample.Address}, object value = 2) + 0x140 bytes    
         System.Windows.Forms.dll!System.Windows.Forms.BindToObject.SetValue(object value) + 0x5d bytes    
         System.Windows.Forms.dll!System.Windows.Forms.Binding.PullData(bool reformat, bool force) + 0x15a bytes    
         System.Windows.Forms.dll!System.Windows.Forms.Binding.Target_PropertyChanged(object sender, System.EventArgs e) + 0x29 bytes    
         [Native to Managed Transition]    
         [Managed to Native Transition]    
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.OnValueChanged(System.EventArgs e = {System.EventArgs}) Line 10479 + 0x11 bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.FireEvent(Infragistics.Win.UltraWinGrid.ComboEventIds id = ValueChanged, System.EventArgs e = {System.EventArgs}) Line 9964 + 0xe bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.FireValueChangedEventHelper(bool hasChanged = true, object newValue = 2) Line 12593 + 0x25 bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.SelectedItemChangeHelper(Infragistics.Win.UltraWinGrid.ComboSelectedItemChangeContext context = Value, object newData = 2) Line 12573 + 0x14 bytes    C#
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.Value.set(object value = 2) Line 7784 + 0x13 bytes    C#
         UltraComboSample.exe!UltraComboSample.Form1.cmbCountry_ValueChanged(object sender = {Infragistics.Win.UltraWinGrid.UltraCombo}, System.EventArgs e = {System.EventArgs}) Line 52 + 0x36 bytes    C#
         [Native to Managed Transition]    
         [Managed to Native Transition]    
         Infragistics2.Win.UltraWinGrid.v9.2.dll!Infragistics.Win.UltraWinGrid.UltraCombo.OnValueChanged(System.EventArgs e = {System.EventArgs}) Line 10479 + 0x11 bytes    C#

    So the ValueChanged event fires once, and the code sets the Value of the second Combo. The Binding on the Combo is tracking this and it updates the field in the data source, which then triggers a ListChanged notification. The currencyManager responds to this by pushing the data out to all bound controls. Since both combos are bound to the same data source, the country combo gets set back to the original value, which hasn't yet been updated in the data source.

    So the problem is that the Binding is not updating the data with the new Country value until after the ValueChanged event has completed. In fact, I think it might not update it until the control loses focus. So one thing you could do is use the ValueChanged event to first update the actual field in the data source before you set the value on the state combo. It kinda defeats the purpose of Binding, but in my experience, the DataBinding behavior has lots of little quirks like this and you might be better off avoiding binding directly, anyway.

    Another option might be to call the BindingManager.EndCurrentEdit inside ValueChanged before you set the State combo's Value. This is essentially the same thing, except it lets the BindingManager set the Country value rather than you doing it yourself.

     

Reply Children
No Data