You can take a look at TextRenderer.MeasureText() .
To calculate the width of the subtitle text, use this snippet:
var width = TextRenderer.MeasureText(caption, SystemFonts.CaptionFont).Width;
You can use the size of your Form, subtract the fixed value for the icon (if available) and the buttons in the upper right corner (depending on the OS version and the visible state of the [Minimize] [Maximize] buttons) and check if all this is positive. This may not give you a completely accurate result, but it is probably the simplest approximation.
So far, this method has apparently calculated a fairly accurate approximation:
/// <summary> /// Calculates an approximation of the available caption width /// Depends on OS and theme /// </summary> /// <returns>Width</returns> private int CalcAvaliableCaptionWidth() { return // Form width Width // Icon - (Icon == null ? 0 : Icon.Width) // Minimize button (26 on Win8) - (MinimizeBox ? SystemInformation.CaptionButtonSize.Width : 0) // Maximize button (26 on Win8) - (MaximizeBox ? SystemInformation.CaptionButtonSize.Width : 0) // Close button (45 on Win8) - SystemInformation.CaptionButtonSize.Width; }
You can try my little WinForm app to check

Source code: https://gist.github.com/CodeZombieCH/b9def0b0d9c41a98593a
Thanks @Plutonix for the hint SystemInformation.CaptionButtonSize .
source share