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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

CurrentCellMoving event

Thread ID:





40733 Feb 10,2006 09:26 PM UTC Feb 14,2006 04:29 AM UTC WinForms 1
Tags: GridControl
Hui Zhong
Asked On February 10, 2006 09:26 PM UTC

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.

Administrator [Syncfusion]
Replied On 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.


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon