Dear all,
I have ultratexteditor "txtmessage" that does not work on VAlign.Middle.
It still show on the top???
this.txtmessage.Appearance.TextHAlign = Infragistics.Win.HAlign.Left; this.txtmessage.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
Oops, sorry about that, that was a typo on my part.
The property is DrawFilter not DataFilter.
public class MiddleAlignDrawFilter : IUIElementDrawFilter { public Boolean DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { drawParams.AppearanceData.TextVAlign = VAlign.Middle; return false; } public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element.GetType() == typeof(EditorWithTextDisplayTextUIElement)) return DrawPhase.BeforeDrawForeground; return DrawPhase.None; } }
When I set the new instance of MiddleAlignDrawFilter class to UltraTextEditor.DataFilter, It says that cannot cast from MiddleAlignDrawFilter to IEditorDataFilter.
what can I do? Where is something wrong??
No, there is no simpler way to do this.
All you have to do is copy this class into your project.
Public Class MiddleAlignDrawFilterImplements IUIElementDrawFilter #Region "IUIElementDrawFilter Members" Private Function IUIElementDrawFilter_DrawElement(ByVal drawPhase As DrawPhase, ByRef drawParams As UIElementDrawParams) As Boolean Implements IUIElementDrawFilter.DrawElement drawParams.AppearanceData.TextVAlign = VAlign.Middle Return False End Function Private Function IUIElementDrawFilter_GetPhasesToFilter(ByRef drawParams As UIElementDrawParams) As DrawPhase Implements IUIElementDrawFilter.GetPhasesToFilter If TypeOf drawParams.Element Is EditorWithTextDisplayTextUIElement Then Return DrawPhase.BeforeDrawForeground End If Return DrawPhase.None End Function#End RegionEnd Class
Public Class MiddleAlignDrawFilterImplements IUIElementDrawFilter
#Region "IUIElementDrawFilter Members" Private Function IUIElementDrawFilter_DrawElement(ByVal drawPhase As DrawPhase, ByRef drawParams As UIElementDrawParams) As Boolean Implements IUIElementDrawFilter.DrawElement drawParams.AppearanceData.TextVAlign = VAlign.Middle Return False End Function Private Function IUIElementDrawFilter_GetPhasesToFilter(ByRef drawParams As UIElementDrawParams) As DrawPhase Implements IUIElementDrawFilter.GetPhasesToFilter If TypeOf drawParams.Element Is EditorWithTextDisplayTextUIElement Then Return DrawPhase.BeforeDrawForeground End If Return DrawPhase.None End Function#End RegionEnd Class
Then set the DataFilter DrawFilter property on the UltraComboEditor to a new instance of the MiddleAlignDrawFilter class.
This will only work when the UltraComboEditor is not in edit mode (does not have focus). When it has focus, it is not possible to align multiline text vertically within the control.
Sorry that I don't understand in the content in the link. It is too complicated to me.
Is there any simple answers for me to correct the code??