Replies
Forgot to say, the above code works when you have added unbound columns unlike the datasource method offered by Mike
Bit of an old post but I've been looking for the solution to this and have come up with this… It copied the data and layout but doesn't do the groupby.. I suspect the save layout code from above will do that bit but anyway..
Sub LoadUltraGrid(ByVal grd As UltraWinGrid.UltraGrid)
Dim tbl As New DataTable
Dim tblcol As New DataColumn
For Each col As UltraWinGrid.UltraGridColumn In grd.DisplayLayout.Bands(0).Columns
If Not col.Hidden Then
tblcol = New DataColumn
With tblcol
.ColumnName = col.Key
.DataType = GetType(String)
.Caption = col.Header.Caption
End With
tbl.Columns.Add(tblcol)
End If
Next
Dim row As DataRow
For Each ugrow As UltraWinGrid.UltraGridRow In grd.Rows
row = tbl.NewRow
For Each col As DataColumn In tbl.Columns
row.Item(col.ColumnName) = ugrow.Cells(col.ColumnName).Value
Next
tbl.Rows.Add(row)
Next
Dim i As Integer = 0
ugrdExport.DataSource = tbl
For Each col As UltraWinGrid.UltraGridColumn In grd.DisplayLayout.Bands(0).Columns
If Not col.Hidden Then
ugrdExport.DisplayLayout.Bands(0).Columns(col.Key).Header.VisiblePosition = grd.DisplayLayout.Bands(0).Columns(col.Key).Header.VisiblePosition
End If
Next
With ugrdExport
.DisplayLayout.Override.CellClickAction = UltraWinGrid.CellClickAction.EditAndSelectText
.DisplayLayout.ViewStyleBand = UltraWinGrid.ViewStyleBand.OutlookGroupBy
.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True
.DisplayLayout.Bands(0).PerformAutoResizeColumns(False, UltraWinGrid.PerformAutoSizeType.AllRowsInBand)
End With
End Sub