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.
Hi, I want to check the column data before the currentcell move to another cell.
If the cell data for some specific column is blank, the error message should popup and the the cell moving should be cancelled.
The code is as follows:
protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
{
base.OnCurrentCellMoving(e);
if (e.colIndex ==3)
{
if (this.Model[e.RowIndex , e.colIndex ].Text.Trim() == "")
{
e.Cancel = true;
}
}
}
I assume, after the moving cancellation, the cursor stops at this cell for the user to enter some data. However, it keeps raising this event.
How to prevent this happen? Thanks.
ADAdministrator Syncfusion Team February 14, 2006 04:29 AM UTC
Hi Hui,
By handling the CurrentCellValidating event, a cell value for a particular column can be forced to be not null. Below is a code snippet.
private void gridDataBoundGrid1_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if(cc.Renderer.ColIndex == 2 && (cc.Renderer.ControlText.Trim() == "" || cc.Renderer.ControlText == null))
{
MessageBox.Show("Cell Value cannot be empty!","Error!",MessageBoxButtons.OK,MessageBoxIcon.Stop);
e.Cancel = true;
}
}
Regards,
Calvin.