Trimming Windows form caption bar text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

In the resize event handler of my Windows form, I want to replace a portion
of the form's title with ellipsis when the form is too small to completely
fit the title. What's the easiest way to generate a trimmed, best-fit caption
title? I'm using .NET Framework 2.0.

Thx.
 
When you control the painting of text, there are overloads of the
Graphics.DrawString method that allow you to specify the overflow handling
method. However, you don't control the painting of the text in the title bar
of the form. So, your best bet is to use Graphics.MeasureString to measure
the size of the title, and truncate it to fit.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 
Back
Top