What will DrawString 'Truncated' produce?

I have a listbox.
The columns are resizable.
If a column is resized so that it is too narrow for the heading, the heading is drawn truncated
Eg This is the Heading becomes This is the He…

How can I know what the ‘truncated’ version is in code?
The heading is still ‘This is the Heading’ if I enquire the value… I need to know what it is actually showing.

That’s Truncated, not condensed.

Ok. Amended the topic.

Condensed will produce a tighter kerning of the characters OR use the Condensed version of the font specified. For example, Avenir Next has a regular and a condensed form:

We crossed …

[quote=437382:@Jeff Tullin]How can I know what the ‘truncated’ version is in code?
The heading is still ‘This is the Heading’ if I enquire the value… I need to know what it is actually showing.[/quote]
You can’t through any mechanism I know of. You would need to get the width of the full title and then chop the text based on the width of the column cutting letters from the right side until the remaining text plus an ellipsis will fit in that column width.

And hope that the framework measurements that truncate the string in the header are the same as you can get with Graphics.Text or StringWidth
I’m not sure they are using the same mechanisms for measuring so you can get different results

If you’re trying to fake something there’s the window BitmapForCaching but you won’t have the text, just a picture of it.

Yup - thats what I tried

Yup - thats what I see.

Ok… not cracking up.

I believe that Jeff’s trying to determine what is being displayed in the ListBox header.

Uhh, we didn’t say THAT :stuck_out_tongue:

Agreed - there’s no really decent way of knowing thats since the headers are almost complely opaque objects
You get almost no events for them to know anything

The whole picture is that I am trying to allow people to resize listbox columns and then export that to a PDf using DynaPDFTable
Christian has nice sample code, and the cells will wrap onto two lines if the text is too wide.
I like that.
But for headings, I have people who are saying that they resize the onscreen listbox, see the headings ‘one way’ but then the PDF that is expected to reproduce the onscreen list, doesn’t match.
They aren’t the same kind of thing, and Im struggling to make them match

What if you “capture” the header into a Picture buffer and then only print the contents from the listbox with that image so that they match?

Or dont use a listbox with headers and create your own (I’ve done something like this)
Then you have 100% control over the headers and can then do whatever you want

I use a second, one row, listbox as the header for another. In this shot, the “Tape sets and archive” header is a second listbox. Its columns are tied to the lower listbox’s columns so that when you resize the “header”, the listbox resizes, as well.

But if the mock header is resizable, the text isnt editable, is it?
I can see it allows you to draw the header in a different style - nice - but that in itself doesn’t change the nature of the problem I need to solve. (It just adds a different place to look for the words)

Thanks anyway for that interesting idea.

You can control all aspects of the text that is drawn. Now all of the differences go away and the things that you expect to work - just work. You can’t manipulate the text aspects of a ListBox header, but that design allows to to manipulate the text as you would in any other cell that ISN’T in the header.

If the text is drawn in the celltextpaint event, sure.
But if the cell is resizable because it is a header, you dont get that event.
If you do get the event, its not a header row, and it isnt resizable.
Have I misunderstood something there?