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

Set focus of SubGrid

I have a dropdown grid cell in a root grid (non-databound), which shows a databound "subgrid". I want this subgrid to become the focus when its dropped. I've tried calling subgrid.Focus() and subgrid.Select() in the SubGrid_VisibleChanged() handler, and in the root grid's _CurrentCellShowingDropDown handler, but that doesn't have any effect. Also... How do I select a specific cell in the subgrid (remember, it's a databound grid) Thanks Eric

4 Replies

AD Administrator Syncfusion Team August 11, 2003 08:51 PM UTC

In CurrentCellShowingDropDown, after the subgrid has been populated, try calling subGrid.ForceCurrentCellMoveTo = true; subGrid.CurrentCell.MoveTo(1,1);


ER ERobishaw August 11, 2003 09:24 PM UTC

Doesn't do it. When the subgrid appears, it doesn't truly have the focus. Hitting the right arrow, for example, closes the subgrid and moves the cursor over on the main grid. Any other ideas? Eric


AD Administrator Syncfusion Team August 11, 2003 10:13 PM UTC

Try the CurrentCellShowedDropDown event. This code worked for me in the DropDownGrid sample. And it also worked when I switched the dropped grid to a GriddataBoundGrid.
private void gridControl1_CurrentCellShowedDropDown(object sender, System.EventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(this.gridControl1[cc.RowIndex, cc.ColIndex].CellType == "GridADropCell")
	{
		GridA.Focus();
		GridA.ForceCurrentCellMoveTo = true;
		GridA.CurrentCell.MoveTo(1,1);
	}
}
Without the focus call, the currentcell shows with a dotted border meaning the grid does not have focus.


ER ERobishaw August 12, 2003 01:21 AM UTC

perfect...I should have seen the "Showed" method. Thanks Eric

Loader.
Live Chat Icon For mobile
Up arrow icon