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?
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
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()
Hello,
Have you tried AfterRowExpanded event ? Does this event works for you ?
I am waiting for your feedback.
Thank you for your feedback. Please do not hesitate to contact with us if you have any further questions.
Thank you for using Infragistics Components.
" if you review the sample you will see that the event occurs once if AfterRowExpanded event has been raised"
I have to study this some more - I hadn't looked at the event in the MyCreation class.
In any event, it seems that this works so until I've tried it and found a performance issue I'll assume there isn't one :-)
The event is called InitializeRowCollection but it occurs when the collection is initialize and not after the rows ware drawn, if want to resize based on VisibleRows, this meant that the rows should be drown. Also if you review the sample you will see that the event occurs once if AfterRowExpanded event has been raised . So please test the sample and feel free to modify it based on your custom needs.
On first glance, that seems as if it could work.
It seems like a complicated way to get to the result, though. Would be nice if there were an event like "InitializeChildRow" instead.
And by using .OnAfterCellCreated isn't this firing once for every CELL - meaning if there are 20 rows with 30 cells this will fire 600 times? I looked but there's no
I'll try it in my project and see what results I get.
Thanks
The other option is to make own implementation of Creation filter, in order to check id the cell of the specific column was created, in order to rise custom event and to call perform auto resize method there. I have implemented my suggestion in a small sample and I hope that this will works for you.
Please let me know if you have any further questions.