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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to programmatically activate a cell in a grid control

Thread ID:

Created:

Updated:

Platform:

Replies:

5409 Jul 2,2003 01:03 AM UTC Jul 3,2003 07:36 AM UTC WinForms 3
loading
Tags: GridControl
jacky chen
Asked On July 2, 2003 01:03 AM UTC

without user clicking on the cell? thanks in advance!

Administrator [Syncfusion]
Replied On July 2, 2003 04:50 AM UTC

You can use code like Dim cc As GridCurrentCell = Me.grid.CurrentCell cc.MoveTo(1, 2, GridSetCurrentCellOptions.SetFocus) If you are doing this when the grid is hidden (like in Form_Load or from another tab that is active), you should also set: Me.grid.ForceCurrentCellMoveTo = True

jacky chen
Replied On July 3, 2003 02:12 AM UTC

thanks clay, but it doesn't really work, what i really want is when user clicks on a cell, it activates not the currently clicked cell but another one that i specify in my code. i tried the line you gave, the cursor disappeared from the currently clicked cell but it doesn't go to the one specified in MoveTo method, and typing on keyboard doesn't produce anything on either cell. could you kindly explain to me what's exactly happening? thanks

Administrator [Syncfusion]
Replied On July 3, 2003 07:36 AM UTC

You cannot call a CurrentCell.MoveTo if the grid is in the process of deactivating or activating a cell. (Sort of like calling a MoveTo from within a MoveTo - the grid does not know how to handle this.) I suspect this is what is going on at the point you called MoveTo. The grid was already in the process. If you want to do someting like this, you can handle MouseDown, remember the cell. And then handle MouseUp, checking to see if it is the same MouseDown cell, and if it is a cell you do not want to click. If it is, then call MoveTo at that point.
private int mouseDownRow = -1;
private int mouseDownCol = -1;
private void gridControl1_GridControlMouseDown(object sender, Syncfusion.Windows.Forms.CancelMouseEventArgs e)
{
	this.gridControl1.PointToRowCol(new Point(e.MouseEventArgs.X, e.MouseEventArgs.Y), out mouseDownRow, out mouseDownCol, -1);
}

private void gridControl1_GridControlMouseUp(object sender, Syncfusion.Windows.Forms.CancelMouseEventArgs e)
{
	int row;
	int col;
	if(	this.gridControl1.PointToRowCol(new Point(e.MouseEventArgs.X, e.MouseEventArgs.Y), out row, out col, -1)
		&& row == mouseDownRow && col == mouseDownCol)
	{
		//change the click from cell 2,2 to 1,1
		if(row == 2 && col == 2)
		{
			this.gridControl1.CurrentCell.MoveTo(1,1);
			//    and/or maybe 
			//this.gridControl1.ScrollCellInView(1,1);
		}
	}
	mouseDownRow = -1;
	mouseDownCol = -1;
}

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.

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

;