CaptionText and ContentText alignment.

4 posts, 0 answers
  1. Bekir
    Bekir avatar
    16 posts
    Member since:
    Sep 2010

    Posted 01 Jul Link to this post

    Hello,

     

    Is there a way to set alignment  (like right, center) of CaptionText and ContentText?

    Kind regards...

  2. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 04 Jul Link to this post

    Hi Bekir,

    Thank you for writing.

    The text element responsible for the caption is located in a panel which is stretched horizontally. This way the caption starts always from the left and the buttons are located on the other end to the right. 

    You can access the caption element and adjust its location by setting its PositionOffset property:
    public Form1()
    {
        InitializeComponent();
     
        this.radDesktopAlert1.Popup.PopupOpened += Popup_PopupOpened;
    }
     
    private void Popup_PopupOpened(object sender, EventArgs args)
    {
        AlertWindowTextAndSystemButtonsElement captionParent = this.radDesktopAlert1.Popup.AlertElement.CaptionElement.TextAndButtonsElement;
        TextPrimitive captionElement = captionParent.TextElement;
        int offset = captionParent.Size.Width / 2 - captionElement.Size.Width / 2;
        captionElement.PositionOffset = new SizeF(offset, 0);
    }

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Bekir
    Bekir avatar
    16 posts
    Member since:
    Sep 2010

    Posted 04 Jul Link to this post

    Hi Hristo,

    Thank you very much for your response.

    This is what I need.

    In addition to that you showed, I add this code for ContentText alignment;

    Thank you again.

    Regards...

    AlertWindowContentElement contentElmn = this.DesktopShortAlert.Popup.AlertElement.ContentElement;
                contentElmn.TextAlignment = ContentAlignment.MiddleCenter; 

  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 05 Jul Link to this post

    Hi Bekir,

    Thank you for writing back.

    The snippet you provided handles the text alignment of the content and I am glad it fits your local setup.

    Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top