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
225
UltraWinGrid: Select All GroupBy and Data Rows
posted

Hello,

I have a UltraWinGrid which has at least one GroupBy column (Outlook Group By).  I want to select all GroupByRows and Data rows on the grid (Even the ones invisible.  I have a function to export the selected rows to excel).  I have problems with selecting ChildBand's (lower level GroupByRows and Data rows).

I can select the first level GroupByRows by this.

theUltraGrid.Selected.Rows.AddRange(theUltraGrid.Rows.All)

 

However, I get 'NullReferenceException' when I try to add ChildBand's rows to SelectedRows.

I am doing something like this. (In the real code I do it recursively)

theUltraGrid.Selected.Rows.AddRange(theUltraGrid.Rows(0).ChildBands(0).Rows.All)

I get the following exception.

{"Object reference not set to an instance of an object."} at Infragistics.Win.UltraWinGrid.Selected.SelectionPositionSortComparer.CompareRow(UltraGridRow rowX, UltraGridRow rowY) ...

I tried it in several different ways but I always get the same exception.  I am wondering if my code has problems or the way I do is completely wrong.  Please give me advice.

 Thanks!

Parents
  • 469350
    Verified Answer
    Offline posted

    There are two problems here.

    First, you cannot select rows on more than one level at a time. This means you cannot select a GroupByRow and one of it's child rows at once. If you select a child rows, the GroupByRow will be de-selected. 

    I think the second issue is with how you are getting the child rows. If the grid is grouped, then theUltraGrid.Rows(0) will be a GroupByRow. A GroupByRow will never have a ChildBands collection. ChildBands only exist on data rows. What you need to do is cast the row into an UltraGridGroupByRow and use the Rows collection to get it's child rows.

Reply Children