I have an ultragrid in edit mode.
I want that the grid validates changes of the active row when a user tries to move the mouse to another row (event without clicking). How could this be achieved?
There are a number of ways to do this.
You could handle the BeforeRowUpdate event.You may also want to set the RowUpdateCancelAction property on the grid to determine what happens when you set e.Cancel to true in BeforeRowUpdate.
Or you could use BeforeCellUpdate or BeforeCellDeactivate if you want more fine control of the validation of each cell.
Hi Mike,
I am not sure I was clear in my initial question: I want to validate the active row when the mouse leaves the active row. I believe I need to capture a mouse event on the grid, isnt'it? Or, is there a property to tell the grid when a row should be updated (on mouse leave, when we press enter etc.)?
Thanks Mike.
It turned out that the MouseEnterElement event was better for my needs, but I managed to make it work with something like this:
Thanks again.
void Grid_MouseEnterElement(object sender, UIElementEventArgs e)
{
Infragistics.Win.UltraWinGrid.UltraGridRow row = e.Element.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridRow)) as Infragistics.Win.UltraWinGrid.UltraGridRow;
if (row == null)
return;
Grid.ActiveRow = row;
}
Well, if that's what you want, you could use the MouseLeaveElement event of the grid and watch for a RowUIElement. You can use GetContext on the RowUIElement to get the row.
Hi,
Sorry to insist, but the requirement is clear: I need somehow to validate a row when the mouse leaves the active row.
If you want the whole story, we are using some custom editors in cells, and these custom editors where badly designed and react on mouse-over. Also the behavior of the custom editor depends on the active row (this is the way it seems to be coded- I do not have the code), and as a result the behavior is wrong in a situation where i) a cell in line 1 is currently in edit mode and ii) the mouse goes over this custom control on line 2. If this late scenario happen, the custom control will base its behavior on line1, and not on line2 as it should be.
This is why I want to ensure that the active row gets validated when the mouse leaves the active row...
I'm not sure I understand what you mean. Why would you want to validate the row based on the position of the mouse? The mouse does not have to be within the row for the user to edit that row. They could be typing in a cell and moving the mouse at the same time, so I'm afraid what you are asking doesn't make much sense to me.
Typically, you would validate the row when the user moves focus to another row or moves focus to another control outside the grid. This has nothing to do with the mouse.
There's a property on the grid called UpdateMode which determines when the grid tries to save the modified data in a row to the underlying data source.