Trimming Windows form caption bar text

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.
 
K

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top