I have an UltraComboEditor set as the EditorComponent of a column in an UltraGrid. The values of this list are set at design time using the designer. The DataValue and DisplayText are set for all items. When adding a row in the TemplateOnBottom I select a value from the dropdown and tab to the next cell. At this point, the dropdown selection clears and doesn't hold the value I just selected. I added a ValueChanged method to see what is happening but the event is never fired.
Other dropdowns that are databound from the database work properly, only the dropdown that has items added at design time is having problems.
I also tried _SelectionChanged and _AfterExitEditMode but none of these are fired. Something is resetting the selected value in that cell when tabbing out of it. I set the ValueMember to the datasource field name for that column.
I removed my items and created a datatable to bind the dropdown at runtime. Same issue, it won't hold it's selected value in the grid cell after tabbing out of it. Nothing unusual about that cell and everything seems to be set correctly.
The screen shot you have here shows that the DataValue of the item "Red" is "255", but the "Str" in front of it indicitaes that it's storing the "255" as a string. I'm guessing your data source is a numeric field which probably can't accept strings, so that's why it's failing. You need to change the DataType on that value. There's a dropdown in the property grid for the DataValue property there where you can change the DataType to the correct type.
Thanks, Mike. I had noticed that but didn't set it because I decided to try binding a data table to it instead, which had an INT field. I did go back to adding the items manually and tried both +32 and +64 data types, but the behavior remains. The data column is set to INT in SQL Server. I will continue to experiment.
Check the DataType property of the grid column at run-time and make sure it matches the data type of your DataValue for each item in the list. If it doesn't match, you will get exactly the behavior you are describing here because the grid will try to update the value in the data source and it will fail so the grid cell will pick up the original value from the data source, since it never changed. You might also try hooking the Error and CellDataError events of the grid to see if they fire, and if so, that might give you more information about why. You could also try setting Visual Studio to break on all run-time exceptions and see if one is occurring - I would be shocked if it wasn't. Oh... on more thing to check - are you handling the InitializeRow event of the grid and maybe setting the value of that cell? If so, you are going to want to check e.ReInitialize before doing that.
Checking the DataType property of the grid column helped. The data was a custom NInt (nullable int) type which I guess did not match the dropdown data types. I forced the column datatype to be INT and that fixed the issue. Thank you for your time.
That good news. :) If you really NEED the column to be some custom type, then it might be possible to get it to work using an editor and a DataFilter. But changing the DataType of the column is much simpler.