Hi,
I have an UltraCombo that is used to select items from a list and set a cell value back in the grid. The grid is bound to a List<MyBusinessObject> data source.
However, the cell is not updated until the user navigates off it where AfterCellUpdate. I want to update the cell/data source immediately at the point the user has selected a value.
What is the best way to do this?
Thanks,
Andez
Hi Andez,
There's no way to commit a single cell to the data source you can only do this for the entire row.
To commit the row, you call the Update method on the row. You can also use grid.UpdateData to commit all pending changes in all rows.
Hi Mike,
I was perhaps not clear.
What I want is to update the underlying row object (ListObject) associated with the grid row when the user selects an item from the UltraCombo. The combo is associated with a grid column in the UltraGrid and provides the user a choice for that column. So assuming my List<BusinessObject> is infact List<Person> which has a property of FavColor of type Color, the list is bound to a List<Color> for examples sake.
So when the user clicks on the Color column cell on a row, the UltraCombo editor will appear and they click on the drop down arrow and select a Color from the list of Colors. At this point the drop down portion of the UltraCombo is closed, but the selected value appears in the UltraCombo in the cell. When the user navigates from the UltraCombo cell, the underlying data source (row's ListObject) is updated from what you are saying. This is all controlled by the UltraGrid I am guessing?
However, I don't want to update the underlying ListObject at this point. I want to update the row's ListObject (Person.FavColor) when the selection is made in the UltraCombo - ie when the user clicks an item.
Can this be done?
Many thanks,
I'm pretty sure I understood the question the first time. But this clarification has me confused. You want to update the ListObject but you don't want to update the ListObject?
When you drop down the list in the cell and select an item, the cell's Text is updated. The underlying ListObject is not updated until you leave the cell or the grid loses focus (based on the UpdateMode property). If you want to write the changes from the cell to the ListObject, there are two ways to do that. One is to call the Update method on the row. This is essentially what happens when you leave the cell or lose focus on the grid, so that's what I suggested you do to achieve what you want.
The only other alternative would be to set the value on the ListObject yourself. You could get the row's ListObject property cast it to the appropriate type and then directly set the appropriate property. This second approach is tricky and I'm not sure it will work very well, as you may run into timing issues or conflicts with the grid.
Hello Andez,
I am glad we were able to assist you. Please let us know if you have any additional questions.
Indeed, AfterCellListCloseUp is what I was after.
Thanks
If the Combo is outside the grid, that will work. But if you are embedding the combo inside the grid cell via the Editor, EditorComponent, or ValueList property on the column or cell, then you might be better off using a grid event like AfterCellListCloseUp or CellChange. You have to be careful, though, as CellChange will fire when the user types into any cell. So they could be in the process of typing something and the partial value might not be valid. So you probably want to limit this to only the Combo column and only when the text in the cell matches an item on the list.
Apologies, yes. Update the ListObject.
I guess I wanted pointers on how to do this.
I am handling the ValueChanged event of the combo and calling the grid.UpdateData method. It works :)
Cheers