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.

Selection and current cell

Thread ID:





1610 Nov 14,2002 10:21 AM Nov 14,2002 01:35 PM Windows Forms 1
Tags: GridControl
Teodorico Morell
Asked On November 14, 2002 10:21 AM

How can I get this behavior (Excel Like or Project Grid like)? When selecting a range of cells with the mouse or keyboard: 1) Pressing any “Arrow key” clears the selections and moves to the desired cell. 2) Pressing “Enter” the current cell cycles through all the cells in the selections. Thanks.

Administrator [Syncfusion]
Replied On November 14, 2002 01:35 PM

You can probably do this by handling the CurrentCellKeyDown event. Here is a try at this.
private void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(this.gridControl1.Selections.Count > 0 
		&& this.gridControl1.Selections.Ranges.AnyRangeContains(GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex)))
		if(e.KeyCode == Keys.Enter)
			GridRangeInfo range = this.gridControl1.Selections.Ranges.GetRangesContaining(GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex))[0];
			range.ExpandRange(1, 1, this.gridControl1.RowCount, this.gridControl1.ColCount);
			int row = cc.RowIndex + 1;
			int col = cc.ColIndex;

			if(cc.RowIndex + 1 > range.Bottom)
				if(cc.ColIndex < range.Right)
					row = range.Top;
					row = range.Top;
					col = range.Left;
			this.gridControl1.CurrentCell.MoveTo(row, col);
			e.Handled = true;
			if(!e.Control && !e.Shift && 
				(e.KeyCode == Keys.Up || e.KeyCode == Keys.Right
				|| e.KeyCode == Keys.Down 
				|| e.KeyCode == Keys.Left))


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.