问题
I'm using DrawText
to draw text onto a DBGrid canvas. The text comes from the database. But when the string contains an ampersand (&) it treats it as an alt
shortcut and underlines it.
For example, what should be
Wool & Silk
winds up being
Wool _Silk
How do I stop this behavior?
回答1:
Suppress prefix handling with the DT_NOPREFIX flag. This is the way forward if you know you do not want any prefixes drawn.
If you want to draw text with both prefixes and ampersand, you can escape the ampersand by doubling it up. So pass && when you want a single ampersand.
You can find all this information, and more, in the documentation.
来源:https://stackoverflow.com/questions/20181949/how-to-stop-drawtext-from-underlining-alt-characters