I want to resize the grid height so that it can right fit all the visible row/row headers. I dont have a way to calculate the height.
I'm sure there's a way to get it since the grid needs this value for scrolling.
Apperciate the help in advance...
hi,
I ve used the following and it holds good for me .......you can try this
i was using the grid within a panel ,so to set the panel's height i ve used the foll way to handle the grid height
dim buffervalue as integer =20
Dim gridHeight As Integer = UltraGrid1.Rows(0).Height * UltraGrid1.Rows.Count + UltraGrid1.DisplayLayout.Bands(0).Header.Height + buffervalue
just check this and finally add some buffer value for the height for asethetic reasons
just to ensure that you get the height of only visible rows ,,use the filteredout ,filterdin properties
hope this helps you out for a work around way,.,.........
hppy koding,
Arun
this might be a solution. I'll try it.
Thanks
Hi. Try this code. I have used recursion to get this to work. Row and cell border thicknesses may effect this code and is untested.
Private Function GetTotalGridRowHeight() As IntegerDim totalHeight As Integer = 0For Each row As UltraGridRow In UltraGrid1.Rows totalHeight += row.Height If TypeOf row Is UltraGridGroupByRow Then Dim groupByRow As UltraGridGroupByRow = DirectCast(row, UltraGridGroupByRow) If groupByRow.IsExpanded Then totalHeight += GetTotalGridRowHeight(groupByRow) End If End IfNextReturn totalHeight End Function
Private Function GetTotalGridRowHeight(ByVal parentRow As UltraGridGroupByRow) As IntegerDim totalHeight As Integer = 0For Each row As UltraGridRow In parentRow.Rows totalHeight += row.Height If TypeOf row Is UltraGridGroupByRow Then Dim groupByRow As UltraGridGroupByRow = DirectCast(row, UltraGridGroupByRow) If groupByRow.IsExpanded Then totalHeight += GetTotalGridRowHeight(groupByRow) End If End IfNextReturn totalHeight End Function
This is really slow when there are groupby rows. I came up with something similar for a grid that can be grouped 3 levels, but its very slow when groups are expanded. I have 270 detail rows grouped into approx 100 level 3, 25 level 1 and 9 level 0 groups. Getting the geight on the level 0 is very fast, but starts taking a few seconds or more as I expand the groupby rows.
All I want the height for is so I can auto-resize an UltraExpandableGroupBox which is inside an UltraFlowLayoutManager to fit the Grid without getting a scroll bar in the grid. I'd thought Autosize would take care of this but apparently not the case. Control.GetPreferredSize returns incorrectly as well. Is there a UI element that would give me the appropriate fitted size?
private int getRowHeight(UltraGridRow r)
{
int height = r.Height ;
if (r.IsGroupByRow && r.IsExpanded)
foreach (UltraGridChildBand bnd in r.ChildBands)
foreach (UltraGridRow cld in bnd.Rows)
height = height + getRowHeight(cld);
}
return height;
public virtual int GetFittedHeight()
if (this.SizeControl == null)
return this.Height;
else
if (SizeControl is UltraGrid)
UltraGrid grd = SizeControl as UltraGrid ;
int height = 0;
foreach (UltraGridRow r in (grd.Rows))
height = height + getRowHeight(r);
foreach (UltraGridBand bnd in grd.DisplayLayout.Bands)
height = height + bnd.Header.Height;
foreach (UltraGridGroup grp in bnd.Groups)
height = height + grp.Header.Height;
UIElement gridElement = grd.DisplayLayout.UIElement;
if (gridElement != null)
if (!grd.DisplayLayout.GroupByBox.Hidden)
UIElement groupByBoxUIElement = gridElement.GetDescendant(typeof(GroupByBoxUIElement));
if (groupByBoxUIElement != null)
height = height + groupByBoxUIElement.Rect.Height;
if (bnd.Summaries.Count > 0)
UIElement footerUIElement = gridElement.GetDescendant(typeof(SummaryFooterUIElement));
if (footerUIElement != null)
height = height + footerUIElement.Rect.Height;
UIElement padUIElement = gridElement.GetDescendant(typeof(RowSplitBoxUIElement));
if (padUIElement != null)
height = height + padUIElement.Rect.Height;
SizeControl.Height = height;
// this.Height = height;
else if (SizeControl is UltraChart)
int height = SizeControl.Height ;
My guess is that the slowness is caused by the forced loading of the child rows, not anything the grid is doing. Loading the child rows of a particular parent tends to be pretty performance-intensive, depending on your data source. So looping through every row and get the children could take some time.
MattWTF said:I'd thought Autosize would take care of this but apparently not the case.
AutoSize is a property that was added to Control in CLR2. So it shows up on every control, whether the control implements it or not. UltraWinGrid does not support this.
MattWTF said:Control.GetPreferredSize returns incorrectly as well.
Same thing here. This is a method on Control and is not supprorted by the grid.
MattWTF said:Is there a UI element that would give me the appropriate fitted size?
No, the WinGrid does not have this functionality. You should Submit a feature request to Infragistics
OK, I see my original reference was redundant, but even using the GroupByRow.Rows as in the earlier example is still slow. Is there a way to get all the expanded groupby row heights without referncing them?
Is there any way to use the UltraWinGrid in an UltraFlowLayoutPanel? I would like to have the grid expand to fit all expanded rows without a scrollbar, while the other controls below it in the flow layout should move down. Is there any way to accomplish this with these controls?
There's no easy way for the grid to determine the height it needs to be in order to fit all the rows. Even looping through the rows like you are doing may not always be accurate.