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

Grid in Cell

Hi, I created a cell in a DataBoundGrid with another grid in it (based on GridGridInCell sample). Now 2 questions: 1. If the user clicks on the cell with the grid in it how can I set the current cell in the embedded grid according to the mouse position? 2. How can I react correctly on the arrow and tab keys? I mean: If current cell of the embedded grid is the first column and I press left arrow or shift+tab the current cell moves the current cell to the cell left of the embedded grid and so on?

3 Replies

AD Administrator Syncfusion Team April 15, 2003 04:37 AM

1) One way you can do this is to listen for the parent grid's cellclick event in the embeddedgrid, and then move currentcell in your handler.
//in the embedded grid's constructor
parent.CellClick += new GridCellClickEventHandler(ClickedOnParentCell);

//the handler
private void ClickedOnParentCell(object sender, GridCellClickEventArgs e)
{
	Point pt = this.PointToClient(Control.MousePosition);
	if(this.GridBounds.Contains(pt))
	{
		int row, col;
		if(this.PointToRowCol(pt, out row, out col, 1))
		{
			this.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.SetFocus);
		}
	}
}

2) In the embedded grid'c constructor, set its WrapCellBehavior property, and hook the WrapNextControlInForm event and handle the moving the the event handler.
//in the constructor
this.Model.Options.WrapCellBehavior = GridWrapCellBehavior.NextControlInForm;

this.WrapCellNextControlInForm += new GridWrapCellNextControlInFormEventHandler(TabToNextParentCell);

//handler
private void TabToNextParentCell(object sender, GridWrapCellNextControlInFormEventArgs e)
{
	GridControl grid = (GridControl) this.Parent;
	grid.Focus();
	if(e.Forward)
		grid.CurrentCell.MoveRight(1);
	else
		grid.CurrentCell.MoveLeft(1);
	e.Cancel = true;
}
	

            


PE Peter April 15, 2003 07:33 AM

Thanx Clay it works. Now another question: How can I do the same (select next parent cell) for up and down arrow? Regards Peter


AD Administrator Syncfusion Team April 15, 2003 11:55 AM

This is not handled by properties. So, I think you will have to derive your grid, override OnKeyDown and do the work there for the up and down arrows.

Loader.
Live Chat Icon For mobile
Up arrow icon