I have a small form that displays some progress information.
Very rarely I have to show a rather long message and I want to be able to resize this form when needed so that this message fits in the form.
So how do I find out how wide string S will be rendered in font F?
It depends on the rendering engine being used. You can basically switch between GDI and GDI+. Switching can be done by setting the
UseCompatibleTextRenderingproperty accordinglyWhen using GDI+ you should use
MeasureString:When using GDI (i.e. the native Win32 rendering) you should use the
TextRendererclass:See this article: Text Rendering: Build World-Ready Apps Using Complex Scripts In Windows Forms Controls