I need to determine the required height to display an UltraGrid. I can get the height required for the rows, by adding up the height of each row, but I don't know how to get the height of the caption.
Can I get the height of the caption?
No. Thanks for your help.
Hi Kipp,
It's good to see that you were able to find a solution even though OfType was not available.
Is there anything further that I can do to assist you regarding this issue?
Thanks.
ChildElements.OfType<T> can't be resolved...
I am using v11.1.
I used this:
internal static int GetGridCaptionHeight(UltraGrid ultraGrid) { int gridHeight = 0; foreach (UIElement childElement in ultraGrid.DisplayLayout.UIElement.ChildElements) { CaptionAreaUIElement captionAreaElement = childElement as CaptionAreaUIElement; if (captionAreaElement != null) { gridHeight = captionAreaElement.Rect.Height; break; } } return gridHeight; }
There are a lot of complexities in determining the required height for an UltraGrid. Due to this complexity, my recommendation is to design around this requirement in order to avoid having to do the calculation.
That being said, I am happy to assist with specific questions. You can find the height of the caption area by leveraging the PLF:
CaptionAreaUIElement captionAreaElement = ultraGrid1.DisplayLayout.UIElement.ChildElements.OfType<CaptionAreaUIElement>().FirstOrDefault(); if (captionAreaElement != null) gridHeight += captionAreaElement.Rect.Height;
Please note that it is necessary to allow the grid to draw at least once before using this method to determine the caption area's height, and also that it may not work as expected if the caption area is not in view.