Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
285
Select first Row in a Grid
posted

I would like to select the "first" row in a grid when it is initially populated. I have been doing this successfully with the following code:

Dim firstRow As UltraGridRow = grid.DisplayLayout.RowScrollRegions(0).FirstRow

If (firstRow IsNot Nothing) Then

firstRow.Activate()

firstRow.Selected = True

End If

I have now introduced a new grid, in which grouping has been switched on at design time. When grouping is enabled, the first (unexpanded) group is selected (or maybe active), which is OK. 

What I don't understand is that if the user switches off grouping, FirstRow is an UltraGridGroupByRow and the above code does not select the first real row (although it appears that it is the active row).

I have tried to compare the properties of the 2 types of grid to determine which property is creating this behaviour, but I haven't been able to. Can someone tell me which it is?  I'd then like to modify the code above so that it will definitely select the first row when grouping is switched off.

Thanks.

 

Parents
  • 37774
    posted

    Instead of getting it off of the RowScrollRegion, why not just look at grid.Rows(0)?  This could still be a GroupByRow when grouped, but I'm not sure why the other property would return a GroupByRow if you're no longer grouped, unless the grid has not repained yet (and therefore not recalculated the rows).

    -Matt

Reply Children