Hello,
I need to validate a cell data in an UltraGrid and return a message to the user and allow him to enter the correct data after the message. My scenario:
- I have an UltraGrid with a fixed column and many dynamic columns after it. The datasource is passed in run-time because of the dynamic columns;
- The fixed column of the grid has a ValueList pointing to an UltraDropDown. This dropdown has an integer value (hidden) as value and a string as display element (not hidden).
- I am validating the data the user enter for that column throught the AfterCellUpdate based on a list of values. Sample code:
private void myGrid_AfterCellUpdate(object sender, CellEventArgs e)
{
if (Convert.ToInt32(e.Cell.Value) != Convert.ToInt32(myList[index])
// Send message to the user
}
The problem is that I need to keep focus on the column the user is updating. But when I enter the data, validate and see the error message the system is changing to the next column and not keeping focus on the column that I am validating.
Has anyone ever had to do a validation like this and keep the focus on the same column that is being validated instead of setting focus on the next column?
What I need is to use something like the CellDataError event, but I cannot raise this event inside the other. Or maybe if there was a mean to invalidate the column data somehow and then the grid will raise CellDataError.
Well I'm new to Infragistics and would appreciate any help you can provide.
[]'s
You have to use BeforeCellDeactivate event to validate your data in the grid. This gives e.Cancel property that allows you to stay in the control (cell) until the validation passes.
Hum... Ok, but how to get the cell value this way? I was using something like CellEventArgs e.Cell.Value, and now I don't have that option.