CurrentCellMoving event

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.

1 Reply

AD Administrator 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.

Loader.
Up arrow icon