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 08:37 AM UTC

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 11:33 AM UTC

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 03:55 PM UTC

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.
Up arrow icon