How to select a row in gridControl
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?
SIGN IN To post a reply.
6 Replies
AD
Administrator
Syncfusion Team
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'').
KI
Kis
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?
AD
Administrator
Syncfusion Team
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;
}
KI
Kis
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 ?
AD
Administrator
Syncfusion Team
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));
}
}
}
KI
Kis
December 21, 2003 10:37 PM UTC
it can work well,thanks again .
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
KI Kis
- Dec 16, 2003 11:51 PM UTC
- Dec 21, 2003 10:37 PM UTC