简体   繁体   中英

What TextFormatFlags.TextBoxControl flag exactly does

I would like to understand what effect has enablig the flag TextFormatFlags.TextBoxControl when using the TextRenderer.DrawText method is called.

I have written an small program and I can't see difference between using it and don't using it.

Also, I inpected the code with the .NET reflector and the flag is passed directly to the native method so I could see what is the effect.

Not sure everything it does, but I use it for one specific effect...

If you use just WordBreak, then if you have a word that is too wide to fit on a line, it just clips that word... it will not break in the middle of a word. But if instead you want it to break within words that are longer than the width, such that nothing is clipped, the you can add TextBoxControl to it and it will do so.

The TextBox Control needs that, because when you are editing text, you really want to be able to see all the characters.

The DataGridView's text columns by default render without it, unless you are editing, and then they edit with it. Right now I'm trying to figure out if there is a setting somewhere in DataGridView or its Columns etc., that will let me specify TextFormatFlags to use when rendering it, so that I can fix that. Any clues on that greatly appreciated.

It looks like it has something to do with Padding, maybe when MultiLines is in play.

From Accurate Font Metrics

Note that we calculate the size of the string using MeasureText and then we add an additional 7 pixels to the height. This is because the TextBox itself has some internal padding that it applies and from our testing it appears to be roughly 7 pixels.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM