This is a migrated thread and some comments may be shown as answers.

CaptionText and ContentText alignment.

3 Answers 74 Views
DesktopAlert
This is a migrated thread and some comments may be shown as answers.
Bekir
Top achievements
Rank 1
Iron
Bekir asked on 02 Jul 2016, 04:37 AM
Hello,

 

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

Kind regards...

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 04 Jul 2016, 02:49 PM
Hi ,

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.
0
Bekir
Top achievements
Rank 1
Iron
answered on 04 Jul 2016, 10:19 PM

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; 

0
Hristo
Telerik team
answered on 05 Jul 2016, 08:27 AM
Hi ,

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.
Tags
DesktopAlert
Asked by
Bekir
Top achievements
Rank 1
Iron
Answers by
Hristo
Telerik team
Bekir
Top achievements
Rank 1
Iron
Share this question
or