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
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();
excellent dear sir, that perfectly serves the purpose.
one more question if you may:
i am currently using an other draw filter for this grid, which hides the selection rectangle (that appears when you select a row), the filter is:
class NoFocusRect : Infragistics.Win.IUIElementDrawFilter { public bool DrawElement(Infragistics.Win.DrawPhase drawPhase, ref Infragistics.Win.UIElementDrawParams drawParams) {return true;} public Infragistics.Win.DrawPhase GetPhasesToFilter(ref Infragistics.Win.UIElementDrawParams drawParams) {return Infragistics.Win.DrawPhase.BeforeDrawFocus;} }
is there a way to merge both filters so that i can take advantage of purposes served by each one of them? (hide rectangle and align group by header).
i don't want to lose one function to the other!
Glad to hear it. :)
works perfectly.
thanks a lot.
You could just combine the code into a single DrawFilter that handles both cases.
public class MyDrawFilter : IUIElementDrawFilter { bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { switch (drawPhase) { case DrawPhase.BeforeDrawForeground: drawParams.AppearanceData.TextVAlign = VAlign.Bottom; return false; case DrawPhase.BeforeDrawFocus: return true; } return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is DependentTextUIElement && drawParams.Element.Parent is GroupByRowDescriptionUIElement) { return DrawPhase.BeforeDrawForeground; } return DrawPhase.BeforeDrawFocus; } }