We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Validation in GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

72838 Apr 8,2008 08:06 AM Apr 11,2008 07:54 AM Windows Forms 1
loading
Tags: GridControl
Ken
Asked On April 8, 2008 08:06 AM

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.


Administrator [Syncfusion]
Replied On April 11, 2008 07:54 AM


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.



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;