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 select a row in gridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

9416 Dec 16,2003 11:51 PM UTC Dec 21,2003 10:37 PM UTC WinForms 6
loading
Tags: GridControl
Kis
Asked On December 16, 2003 11:51 PM UTC

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 07:06 AM UTC

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 11:04 PM UTC

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 05:41 AM UTC

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 10:14 PM UTC

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 10:24 PM UTC

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 10:37 PM UTC

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.

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

;