Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
340
Group By Row - text alignment
posted

hi,

i have an UltraWinGrid that has one group, i want to vertically align the text inside this row to bottom, while it is aligned by default at the middle.

i tried in Grd_InitializeGroupByRow:
e.Row.Appearance.TextVAlign = VAlign.Bottom;

e.Row.CellAppearance.TextVAlign = VAlign.Bottom;

no result.

how can i change the alignment of the text inside the groupbyrow?

thanks

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Ahmad, 

    Typically, the GroupByRow auto-sizes it's height to the text. So there is no extra space in which to align the text vertically. But I suppose if you are adjusting the height of the GroupByRow by either explicitly setting the Height or maybe if you have multiple summaries displaying in the GroupByRow for a single column the height of the row would increase. 

    The Appearance object is a sort've generic common object that we use across the whole WinForms suite. So not every object supports every property of the Appearance. And in this case, the GroupByRow apparently does not support the TextVAlign property - probably because, as I said, the row usually sizes to the height of the text and hardly anyone ever needed to align the text vertically. 

    What you can do to solve this probably is to use a DrawFilter. The DrawFilter will allow you to set the text alignment of the UIElement at the drawing level. It's a pretty simply DrawFilter for this and the code would look something like this: 

        public class MyDrawFilter : IUIElementDrawFilter
        {
            bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
            {
                drawParams.AppearanceData.TextVAlign = VAlign.Bottom;
                return false;
            }
    
            DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams)
            {
                if (drawParams.Element is DependentTextUIElement &&
                    drawParams.Element.Parent is GroupByRowDescriptionUIElement)
                {
                    return DrawPhase.BeforeDrawForeground;
                }
    
                return DrawPhase.None;
            }
        }

    So you can include this class in your project and then just assign an instance to the grid in the Form_Load or the constructor or somewhere during your app's initialization like so: 

    this.ultraGrid1.DrawFilter = new MyDrawFilter();

Children