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.

How to select a row in gridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

9416 Dec 16,2003 06:51 PM Dec 21,2003 05:37 PM Windows Forms 6
loading
Tags: GridControl
Kis
Asked On December 16, 2003 06:51 PM

I use gridControl to display some data,and i set ListBoxSelectionMode=One.when I click one row,it will select that row. now I want to select a row after I load data,and some rows can't select ,that is select these row ,it always select the first row . how to do this?

Administrator [Syncfusion]
Replied On December 17, 2003 02:06 AM

One way to do this would be to use grid.CurrentCell.MoveTo to position the current cell where you want it. With ListBoxMode set to One, this should also select the row. (If you are doing this initially before the grid has been displayed, you may also need to set grid.ForceCurrentCellMoveTo = true to make the moveto ''take'').

Kis
Replied On December 17, 2003 06:04 PM

thanks Clay Burch but when I click the No. 9 row and I want it can Focus in the NO. 5 row,it can't work. how to set this?

Administrator [Syncfusion]
Replied On December 18, 2003 12:41 AM

Try handling the CurrentCellActivating event and setting the e.RowIndex there.
private void gridDataBoundGrid1_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
{
	if(e.RowIndex == 9)
		e.RowIndex = 5;
}

Kis
Replied On December 18, 2003 05:14 PM

yes ,I do by this ways too,it can work when I use the key down and up ,but when I click on the No. 9 row the focus is still in the No. 9 row. why ?

Administrator [Syncfusion]
Replied On December 18, 2003 05:24 PM

Try this.
private void gridControl1_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
{
	if(e.RowIndex == 9)
	{
		e.RowIndex = 5;
		if(Control.MouseButtons == MouseButtons.Left)
		{
			this.gridControl1.Selections.Clear();
			this.gridControl1.Selections.Add(GridRangeInfo.Row(5));
		}
	}
}

Kis
Replied On December 21, 2003 05:37 PM

it can work well,thanks again .

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.

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.

;