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. Image for the cookie policy date

Disable a cell and moving away from it

Hi, I have a GridControl with the following properties set: this.gridControl.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow; this.gridControl.EnterKeyBehavior = GridDirectionType.Right; In my last enabled cell in each column, the user can enter an integer. If this integer i 0, the cell's Enabled-property is set to false. I do this listening to the Validating-event. This works fine for all cell's except for the last enabled row in the last column. Here the cursor simply stays in the cell, even though is isn't enabled! I've tried listening to the Validated-event and the using the MoveTo-method, but the a dialogbox, with this error appeas: "Deactive called while the current cell was in process of activating or deactivating a cell"??? Is there a few so solve my problem?

6 Replies

Administrator May 28, 2003 07:47 AM UTC

Can you use the GridWrapCellBehavior.WrapGrid setting? This will move to the upperleft when you leave the lowerright cell. (It will not leave the current cell where it was which is what I think is happening now). If you can't use WrapGrid, then try handling this event and explicitly moving the current cell where you want it if you are moving off the bottom right cell.
private void gridDataBoundGrid1_QueryNextCurrentCellPosition(object sender, GridQueryNextCurrentCellPositionEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.Renderer.ControlText == "1"
		&& e.ColIndex == this.gridDataBoundGrid1.Model.ColCount + 1
		&& e.RowIndex == this.gridDataBoundGrid1.Model.RowCount 
		)
	{
		//move it back a column
		cc.MoveTo(e.RowIndex, e.ColIndex - 2); 
		e.Handled = true;
		e.Result = false;
	}
}

Administrator May 28, 2003 10:49 AM UTC

Well, I can't get WrapGrid working, but instead i discovered NextControlInForm which I can use to move focus... However, I'm not sure I'm using it the right way - is there an example somewhere showing how to use it? I haven't been able to find any...

Administrator May 29, 2003 10:06 AM UTC

Attached is a try at doing this. You may have to tweak the code to work for your particular situation. It uses WrapGrid and QueryNextCurrentCellPosition to try to handle things. If you type a 0 in the last column that cell becomes disabled and will be skipped the next time you try to enter in.

Administrator May 29, 2003 10:07 AM UTC

Forgot to attach the sample....

Administrator June 2, 2003 11:10 AM UTC

Try entering this after InitializeComponent(); in the constructor: gridControl1[1,1].Enabled = false; And then er a 0 (zero) in row 3, column 4... and press Enter until the cursor should jump from row 2 to 3... then nothing happens?

Administrator June 2, 2003 01:11 PM UTC

You can turn off the WrapGrid and handle all the movement in QueryNextCurrentCellPosition. This way you control exactly the currentcell movement. Attached is a sample.
Loader.
Live Chat Icon For mobile
Up arrow icon