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

Programatically select and scroll to a row in GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

52852 Dec 5,2006 12:03 PM UTC Dec 5,2006 01:24 PM UTC WinForms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 5, 2006 12:03 PM UTC

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.

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On December 5, 2006 01:24 PM UTC

Thanks Haneef !

Any suggestions to resolving the 3rd issue?

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

;