I've got a UltraWinGrid bound to a UltraDataSource. I've used design-time to create the column/band layouts in the UltraDataSource. The UltraWinGrid is design-time bound to the UltraDataSource.
In code in my LoadData() routine, I load the UltraDataSource row by row, band by band (one root band, one child band("Location")) like this:
For Each t As RFATariff In Card.TariffList.Values Dim dr As UltraDataRow = dsPricing.Rows.Add
dr("TariffKey") = t.TariffKey
... etc ...
Dim LocationRows As UltraDataRowsCollection = dr.GetChildRows("Location") For Each l As RFALocation In t.LocationList.Values Dim ldr As UltraDataRow = LocationRows.Add ldr("LocationKey") = l.LocationKey ...etc...
Next Next For Each c As UltraGridColumn In dgrPricing.DisplayLayout.Bands(0).Columns c.PerformAutoResize(PerformAutoSizeType.AllRowsInBand, True) Next For Each c As UltraGridColumn In dgrPricing.DisplayLayout.Bands("Location").Columns c.PerformAutoResize(PerformAutoSizeType.AllRowsInBand, True) Next
All this works fantastic.
My problem comes when I want to reload the form.
I tried dsPricing.Rows.Clear() but this cleans out the layout of the ultradatasource....
I hate it if I'm missing something simple, but how can I just clear out the datarows from the entire data source without resetting properties/settings at the same time?
Hi,
What exactly do you mean by this?
grantboggs said:I tried dsPricing.Rows.Clear() but this cleans out the layout of the ultradatasource....
Clearing the rows collection should not have any effect on the data structure. The Bands and columns should not be affected by this.
Hi Mike,
What I meant was:
When you do the dsPricing.Rows.Clear(), the associated UltraGrid loses all it's layout information.
It's so strange to me that you can create an UltraGrid layout in the design-time designer, attach the UltraDatasource and everything works fine-- but clear out the rows in the UltraDatassource and all your grid layout settings go with it.
I expected the grid component to maintain it's layout settings even if the bound datasource was removed or empty. ;-)
I've since solved the issue by moving the grid layout code into the Initialize_Layout event. Everything working fine now.