Desktop Alert Not Resizing Accordingly To the ContentText Set

7 posts, 2 answers
  1. Jenson
    Jenson avatar
    25 posts
    Member since:
    Oct 2012

    Posted 03 Jun 2012 Link to this post

    Hi,

    I would like to know whether anyone else is facing the same issue like mine.

    I'm using RadDesktopAlert on Visual Studio 2008 (C#), and I never set any button to trigger the desktop alert. 

    I'm calling it whenever I want to display the alert.

    I leave the FixedSize value to its default 0, 0 (which should resize automatically according to the content text set.

    However, I noticed that's not the case, they will always put in the text to fit the "fixed" size, after that, the remaining text exceeded the alert window size would be replaced with "..." at the bottom of the displayed text.

    May I know whether this is a bug or some settings issue?

    Thank you.

    Regards,
    Jenson
  2. Jenson
    Jenson avatar
    25 posts
    Member since:
    Oct 2012

    Posted 06 Jun 2012 Link to this post

    Now I also noticed if I used <html> formatting in the ContentText, it will not display "..." for text exceeding the display window size, it would just not be displayed.

    For example, this is the formatting I put for ContentText

    strContent = "<html>Item for "
       + "<br>" + "Item Code: " + strRawMaterialCode
       + "<br>" + "Item Name: " + strRawMaterialName
       + ", has been deleted successfully. ";

    Which I will pass to a private function ShowDesktopAlert(string, string);

    private void ShowDesktopAlert(string strCaption, string strContent)
    {
        try
        {
            rdaRawMaterial.CaptionText = strCaption;
            rdaRawMaterial.ContentText = strContent;
            rdaRawMaterial.Show();
        }
        catch (Exception ex)
        {
            MessageBox.Show("Unable to display Desktop Alert.", "No Desktop Alert");
        }
    }

    But it's displayed incompletely. It would only displayed up to the first <br>.

    Thanks.

    Regards,
    Jenson
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 07 Jun 2012 Link to this post

    Hi Jenson,

    Thank you for contacting us.

    Currently, RadDesktopAlert does not support AutoSize. However, you can measure the text you want to display before you open the alert and then set its FixedSize property. The following sample demonstrates this:
    public Form1()
    {
        InitializeComponent();
        this.radDesktopAlert1.FixedSize = new System.Drawing.Size(330, 330);
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        //20 - vertical margins, 70 - caption height
        MeasurementGraphics graphics = MeasurementGraphics.CreateMeasurementGraphics();
        SizeF sizeF = graphics.Graphics.MeasureString(this.radDesktopAlert1.ContentText, this.Font, this.radDesktopAlert1.FixedSize.Width - 20);
     
        this.radDesktopAlert1.FixedSize = new Size(this.radDesktopAlert1.FixedSize.Width - 20, (int)sizeF.Height + 70);
        this.radDesktopAlert1.Show();
    }

    Note that the above method will work with plain text only. If you need to use HTML-like formatted text, then the approach would be slightly different.

    I hope this will help you. Please let me know if you have any additional questions.

    Regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  5. Jenson
    Jenson avatar
    25 posts
    Member since:
    Oct 2012

    Posted 07 Jun 2012 Link to this post

    Dear Ivan,

    Thanks for your reply. May I know how should I achieve this if I want to use HTML-like formatted text? (As shown in the code I've pasted in my first post).

    As plain text is good if I only want to display a short and sweet message.

    Btw, any plan from Telerik to enable the AutoSize of FixedSize value?

    Thank you.

    Cheers,
    Jenson
  6. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 07 Jun 2012 Link to this post

    Hello Jenson,

    Here is how you can measure the text when you also have some HTML-like formatting:
    private void radButton1_Click(object sender, EventArgs e)
    {
        this.radDesktopAlert1.Popup.LoadElementTree();
        RadDesktopAlertElement alertElement = ((DesktopAlertPopup)this.radDesktopAlert1.Popup).RootElement.Children[0] as RadDesktopAlertElement;
        alertElement.ContentElement.Measure(new SizeF(this.radDesktopAlert1.FixedSize.Width, float.PositiveInfinity));
        this.radDesktopAlert1.FixedSize = new Size(this.radDesktopAlert1.FixedSize.Width, (int)alertElement.ContentElement.DesiredSize.Height + 50);
        this.radDesktopAlert1.Show();
    }

    This solution should also work if the text is plain.

    As to adding AutoSize support to RadDesktopAlert, no, we currently do not have plans or time frames for adding such a feature. However, this feature sound reasonable and therefore I have logged it in our Public Issue Tracking System as a feature request. Here is the link to the PITS item. You can subscribe to it to track if for changes or vote for it to increase its priority.

    Your Telerik points have been updated. Feel free to ask if you have any future questions.

    Greetings,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  7. Jenson
    Jenson avatar
    25 posts
    Member since:
    Oct 2012

    Posted 07 Jun 2012 Link to this post

    Dear Ivan,

    Thanks for the helps and efforts.

    I would love to see this features coming out, but so far no one has voted for it yet. I've just cast my vote for this.

    I commented there that there should be a restriction on the maximum of characters to be allowed in RadDesktopAlert ContentText, otherwise, people might abuse the flexibility and blow up the Alert to fill the whole screen, which definitely defeat the purpose of using a RadDesktopAlert, unless that's one of the flexibility Telerik would like to give the rights back to developers to decide how they want to use their Telerik controls :-)

    Thank you!

    Cheers,
    Jenson
  8. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 12 Jun 2012 Link to this post

    Hello Jenson,

    The PITS item was created at the moment I wrote my previous post so not having any votes is pretty normal. Thank you very much for your feedback. We really appreciate that you have shared it with us.

    Should you have any future questions, do not hesitate to contact us.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready