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.
Unfortunately, activation email could not send to your email. Please try again.

CurrentCellMoving event

Thread ID:

Created:

Updated:

Platform:

Replies:

40733 Feb 10,2006 04:26 PM Feb 13,2006 11:29 PM Windows Forms 1
loading
Tags: GridControl
Hui Zhong
Asked On February 10, 2006 04:26 PM

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 13, 2006 11:29 PM

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.

CONFIRMATION

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.

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.

;