AD
Administrator
Syncfusion Team
October 24, 2007 07:51 PM UTC
Hi Jane,
Thank you for your interest in Syncfusion products.
You can validate the cell using CurrentCellValidating event.You can also handle CurrentCellKeyDown and CurrentCellKeyPress events , validate the current cell and display the error message.
The following code snippet validates a double value and changes the message.
You can also use ErroProvider to display the error message.
[C#]
private void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
String s = cc.Renderer.ControlText;
try
{
Double d = double.Parse(s);
}
catch
{
cc.ErrorMessage = "My error message";
}
}
}
Please let me know if this meets your requirement.
Regards,
Jaya
WJ
Wen Jiang
October 24, 2007 10:41 PM UTC
Jaya,
This partially helps.
I tried CurrentCellValidating, CurrentCellKeyPress and CurrentCellKeyDown, all don't pop error even there is error when Enter is hit. Eventually I used CurrentCellValidating, and redirect the focus to the current cell, then it works fine.
Thanks a lot!
Jane
>Hi Jane,
Thank you for your interest in Syncfusion products.
You can validate the cell using CurrentCellValidating event.You can also handle CurrentCellKeyDown and CurrentCellKeyPress events , validate the current cell and display the error message.
The following code snippet validates a double value and changes the message.
You can also use ErroProvider to display the error message.
[C#]
private void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
String s = cc.Renderer.ControlText;
try
{
Double d = double.Parse(s);
}
catch
{
cc.ErrorMessage = "My error message";
}
}
}
Please let me know if this meets your requirement.
Regards,
Jaya