Hi - I have a WinGrid with two bands, master/detail relationship. When the the child band is revealed for a parent record, I want to resize the columns in the child rows based on visible data. I can do that in code no problem, but I can't find an event to use to fire the resize - I tried AfterRowExpanded on the parent row but it seems no data rows are visible at that time. I don't want to use AllRowsInBand because there are 40,000 of them and I am only showing five at a time.
It appears that when the code executes in the AfterRowExpanded that the rows either are not visible or do not contain data. I expand and columns are not resized. I fire the same code with a button when rows are visible and they resize correctly.
Any suggestions?
See my initial post and the one above yours - that was and is the event and code I'm using.
Here (I think) is the issue. The AfterRowExpanded event fires BEFORE the child rows are populated. So when the PerformAutoResize is done there is no data to size with.
If I run the code in the AfterRowExpanded event, child rows are sized to their headers.
If I hook up a button to call the same code iterating the columns and resizing after the rows are displayed it sizes the rows correctly using data and headers (AutoResizeColumnWidthOptions.All).
I have the right code but I need to use an event AFTER the child rows are populated. What event could I use? I don't want InitializeRow because that would resize the columns over and over for every row displayed - a performance hit.
Hello,
Have you tried AfterRowExpanded event ? Does this event works for you ?
I am waiting for your feedback.
Interesting ...
My code is like this ... bands(1) is of course the child band.
You are explcitly setting the width of the columns, whereas I was looking at the data to size with. I don't want to try and predefine column widths, I want them dynamically resized.
Dim band As UltraGridBand = TsHeaderUltraGrid.DisplayLayout.Bands(1) Dim column As UltraGridColumn For Each column In band.Columns ' Timesheet_DetailUltraGrid.DisplayLayout.Bands(0).Columns column.PerformAutoResize(PerformAutoSizeType.VisibleRows, AutoResizeColumnWidthOptions.All) Debug.WriteLine("Column " & column.FormulaAbsoluteName & " " & column.Width) Next TsHeaderUltraGrid.Refresh()
How do you access the child rows? This code seems to work as expected:
Private Sub grd_AfterRowExpanded(sender As Object, e As Infragistics.Win.UltraWinGrid.RowEventArgs) Handles grd.AfterRowExpanded
Dim row As Infragistics.Win.UltraWinGrid.UltraGridRow
If e.Row.HasChild Then
For Each row In e.Row.ChildBands(0).Rows
row.Cells(0).Column.Width = 200
Next
End If
End Sub