Home All Groups Group Topic Archive Search About

Trimming Windows form caption bar text

Author
19 Oct 2007 9:12 AM
PacManFan
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.

Author
19 Oct 2007 11:58 AM
Kevin Spencer
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

Show quote
"PacManFan" <PacMan***@discussions.microsoft.com> wrote in message
news:44593413-9C00-4ADF-BB59-3C959237AB5C@microsoft.com...
> 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.
>
>

AddThis Social Bookmark Button