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

Programatically select and scroll to a row in GridDataBoundGrid

How do I programatically select a row in a GridDataBoundGrid? If the row to be selected is beyond current view layout of the grid, what would be the best way to scroll to this row given that only row index is known?

I have tried the following -

...
gridDataBoundGrid.Selections.Clear();
...
gridDataBoundGrid.Selections.SelectRange(rowIndex, true);
gridDataBoundGrid.SetTopRow(rowIndex);


But, the above code has following issues -

1. Although the row is selected, the row header doesn't show an indicator that the row has been selected, as it would normally do when a user clicks on a row.

2. Occasionally, only the first few columns of the row are highlighted rather than the entire row. (This is quite sporadic!)

3. If the above piece of code is executed from within a CurrentCellEditingComplete event handler and the row to be selected is beyond current view layout, the grid behaviour I see is - the grid scrolls and briefly selects the row and then immediately the selection is changed and focused on to the range of rows that covered the scrolled area.

2 Replies

AD Administrator Syncfusion Team December 5, 2006 12:33 PM UTC

Hi,

Use the Model.Selections property to manages selected ranges in the grid. It allows you to add and remove selections, determines selection state of a specific cell. Use the below code to select a row in a grid.

this.gridDataBoundGrid1.Model.Selections.Add(GridRangeInfo.Row(RowIndex
this.gridDataBoundGrid1.SetTopRow(RowIndex);

To show the RowIndicator, you need to set the Binder.CurrentPosition property of the Grid. Here is a code snippet

this.gridDataBoundGrid1.Binder.CurrentPosition = this.gridDataBoundGrid1.Binder.RowIndexToPosition(RowIndex) ;

Best Regards,
Haneef


AD Administrator Syncfusion Team December 5, 2006 01:24 PM UTC

Thanks Haneef !

Any suggestions to resolving the 3rd issue?

Loader.
Live Chat Icon For mobile
Up arrow icon