-1

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?

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • Jerry, doesn't doubling up the ampersand do that? – MartynA Nov 24 '13 at 22:34
  • 3
    "doesn't show any research effort" comes really true if a simple google search for the keywords *drawtext ampersand* will bring up the answer at first search result. So what problem are you talking about? If people did not use a global search engine, do you think they will do a search here? – Sir Rufo Nov 24 '13 at 23:47

1 Answers1

5

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490