Search code examples
.netinfragisticsultrawingrid

Why is my UltraGridRow ListObject null after loading a serialized DisplayLayout


I am using an Infragistics UltraGrid in my WinForms application. Infragistics v13.1.

I have recently added code to save grid layouts in a binary serialized format and load them back using the CopyFrom method on the DisplayLayout object.

While I load one of these saved layouts, the grid is modified appropriately and data still shows correctly in the grid, but any time I ask for a ListObject on a row, it returns null. The datasource for the grid is a BindingSource whose DataSource is a BindingList (this data is not changed when the layout is loaded).

Save:

Dim MS As New IO.MemoryStream()
ugl.Save(MS, Infragistics.Win.UltraWinGrid.PropertyCategories.All)
Return MS.ToArray()

Load:

Private Function ConvertToUltraGridLayout(data As Byte()) As UltraGridLayout
    Dim ugl As New UltraGridLayout()
    Dim MS As New IO.MemoryStream(data)
    MS.Seek(0, IO.SeekOrigin.Begin)
    ugl.Load(MS, Infragistics.Win.UltraWinGrid.PropertyCategories.All)
    Return ugl
End Function

dgrServices.DisplayLayout.CopyFrom(ConvertToUltraGridLayout(lOption.Layout))

What do I need to do to get the ListObject to be non-null?

Thanks!


Solution

  • The code I was using to get the row ListObject was dgrServices.Rows. The reason DisplayLayout that I am loading has a Group By applied. This causes the rows hierarchy to change so that it can put the special group header rows. These, correctly, have no ListObject.

    Now I just need to figure out the easiest way to get the databound rows in the grid and skip over these special group by header rows.

    http://help.infragistics.com/Help/Doc/WinForms/2012.1/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v12.1~Infragistics.Win.UltraWinGrid.UltraGridBase~Rows.html