Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Show UltraDesktopAlert on the bottom left of my application
posted

Hi,

I want to show an UltraDesktopAlert with errors on the bottom left of my application (not the bottom of the screen).
To achieve this, I use code like this:

info.ScreenPosition = Infragistics.Win.Misc.ScreenPosition.Manual
Dim loc As New System.Drawing.Point
loc.X = Me.Left
loc.Y = Me.Top + Me.Height - UltraDesktopAlert.Height (<- this property doesn't exist)
info.ScreenLocation = loc

The text in the alert is variable. How can I resolve the exact height of the desktop alert (because this is calculated in internal functions of the control)? I also tried to set the FixedSize but the same issue here: how can I calculate the correct height needed to display the whole text?

  • 1500
    Verified Answer
    Offline posted

    Hello,

    Calculating string length can be done using the graphics objects and its MeasureString method:

    using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1)))
    {
        SizeF size = graphics.MeasureString("Hello there", new Font("Segoe UI", 11, FontStyle.Regular, GraphicsUnit.Point));
    }

    Regarding height, you can check Font.Height property, and then based on the number of lines you want to have there, calculate the height needed to display the text.

    Should you have any other questions, please let me know.

    Sincerely,

    Tihomir Tonev
    Associate Software Developer
    Infragistics