The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I use dataTable as the dataSource of a GCC. The feature I want is when user write data into the GCC and hit key Enter, I want the data in the current cell to be validated in my defined way and pop up error if there is any.
But I haven't found the right event to fire, I have tried TableControlCurrentCellKeyDown, TableControlCurrentCellKeyPress, but neither accepts key Enter.
ADAdministrator 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
WJWen JiangOctober 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.