I am using Infragistics.Win.UltraWinGrid.UltraCombo for getting the Drop down List.
and hence selected, DropDownStyle = UltraComboStyle.DropDownList; But I'am losing it's value (i.e. udRuleContext.Value) when I click on drop-down button.
I am using following Method to bind RuleCombo and 'udRuleContext' is object of 'UltraCombo',
private void BindRuleCombo() { if (this.udRuleContext.DataSource != null) { this.udRuleContext.DataSource = null; }
this.udRuleContext.DataSource = this.listSelRules; this.udRuleContext.DisplayMember = "RuleName"; this.udRuleContext.ValueMember = "RuleName"; }
So, how can I tackle this issue so that the field's current value should not be lost while clicking the drop-down button?
I am using Infragistics Professional 2017 vol 1.
Hello AOps,
I have been investigating this issue you are seeing in this case, and from the code that you have provided, the largest reason that I can think of that a value would be lost when going into edit mode on a drop-down by clicking the drop-down button would be that your ValueMember of “RuleName” does not match the data type of the underlying column in your UltraGrid.
Would it be possible for you to please verify that this is or is not the case? If it is not, would it be possible for you to please provide an isolated sample project that shows this behavior you are seeing so I may investigate further?
Please let me know if you have any other questions or concerns on this matter.
Hi Andrew,
this issue was not there in Infragistics version 2010.2 . But when we started using Infragistics version 2017.1 , this issue is coming.
Similarly, for now, i have tried to give DropDownStyle as UltraComboStyle.DropDown then, it works fine as the current value is preserved. Why can't we do this with DropDownList ?
But the proble with DropDown option is it allows value which are not in the drop-down collection and I don't want that.
Will you please suggest me, is there any properties defined by infragistics to overcome this issue with DropDownList ?
I believe that before I can reliably give you any recommendations on this matter, I will need to reproduce the behavior that you are seeing locally on my end, as I am unsure why a drop-down would lose its value/text when opening the drop-down when DropDownStyle is set as DropDownList.
As such, would it be possible for you to please provide an isolated sample project that depicts the issue you are seeing. Note, our forums will only allow attachments that are < 1MB size, and so I would recommend deleting the bin and obj folders of your isolated project before attaching it.
Thank you for the solution. It helped me resolving the Issue.
One of the requirements of using DropDownList style is that the user cannot select a value that is not on the list. What's happening here is that you are handling BeforeDropDown and setting the DataSource on the UltraCombo. This causes the UltraCombo to remove all of the existing rows (including the row that matches the current value) and thus the Value gets set to null.
Generally, it's not recommended to set the DataSource of the combo in BeforeDropDown. I expect you are doing that because your combo's list needs to change based on some other combo or some other UI option. But if that's the case, then changing the DataSource is not really the best way to go about it. It would be best to keep all possible values available on the list and filter out the ones that are not currently valid.
If that's not the case, and you are changing the data source for some other reason, then you could get this to work in your sample by simply storing and then restoring the combo's Value. Of course, this will result in events like ValueChanged getting fired twice. So you might want to unhook them while you do it. Something like this:
private void UltraDropdown_BeforeDropDown(object sender, CancelEventArgs e) { var value = this.ultraCombo1.Value; this.ultraCombo1.ValueChanged -= UltraCombo1_ValueChanged; try { InitData(); this.ultraCombo1.DataSource = ultraCombo1Data; this.ultraCombo1.Value = value; } finally { this.ultraCombo1.ValueChanged += UltraCombo1_ValueChanged; } }
Please find below sample code,
/community/cfs-file/__key/communityserver-discussions-components-files/1040/8422.WindowsFormsApplication1.zip
Steps to reproduce:
1. select any value from the dropdown list.
2. Then again click on dropdown button and you will observe that the initial value in combo is lost.
But, It should not be lost. Will you please check it and let me know how to fix it?