Thursday, January 6, 2011

Making Selected Row Visible in UltraWinGrid

I was facing a problem with Infragistics UltraWinGrid object. There were about 15 rows in the grid. Due to size of form only 8 were visible at a time. The first rows was fixed, so it cannot be moved by scrolling.

To edit row a popup form is opened on double clicking the row and a button on the form. On successful saving of editing information in popup form, parent form's grid is refreshed from database.

Upon refreshing if the very first row (just below the fixed row) was selected or popup was opened by clicking on button when selected row was not visible, it is not scrolled to view.

Unfortunately windows grid does not contains a method like web grid which scrolls selected row to view (ScrollToView).

After some hit and trail I found the following solution:

myGrid.ActiveRowScrollRegion.FirstRow = row;//row is selected row (can get using myGrid.ActiveRow)