Validation in GDBG

I am trying to validate a row in a GDBG. When I use CurrentCellValidating, the user can tab over a cell and leave it blank. When I use CurrentCellMoving, the user can select another control with the mouse, leaving cells blank. When I use RowLeave, I cannot move the CurrentCell back to the cell with bad data with MoveTo. What would you suggest I use? I need to be able to check the users input and verify that cells are not left blank whenever the user leaves the cell, row, or grid, and if data is invalid, show the user which cell is bad.


1 Reply

AD Administrator Syncfusion Team April 11, 2008 11:54 AM UTC


Hi Ken,

Thanks for the interest in Syncfusion products.

You can handle CurrentCellValidating as well as CurrentCellKeyDown and check if the CurrentCell is empty. You can check for the CurrentCellKeyDown if the key is Tab key and also if the CurrentCell is empty. Please refer the following code snippet.


private void gridDataBoundGrid1_CurrentCellValidating(object sender, CancelEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
string s = cc.Renderer.ControlText;
if (s == "")
{
Console.WriteLine("Empty Cell !!");
e.Cancel = true;
}
}
private void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Tab)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
string s = cc.Renderer.ControlText;
if (s == "")
{
Console.WriteLine("Empty Cell !!");
e.Handled = true;
}
}
}


Please refer the sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/F72838/main.htm


Please let me know if this is not what you needed.

Regards,
Asem.



Loader.
Up arrow icon