DrawString - few font styls in the same row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is it possible to draw string with few font styls, like in WORD (i.e. Bold
and Underline) at the same line, on the same text ?

and is it possible that part of the line will be bold and the other one not ?

Thanks,
Gidi.
 
Hi Gidi,

If you're using GDI or GDI+ to render text then there is no simple way,
AFAIK, but it can be done. I believe that you'll have to calculate the
position of each contiguous block of formatted text and render it, in-place.

The TextRenderer.DrawText (2.0 framework) and Graphics.DrawString methods
both accept Font parameters. You can specify any combination of FontStyle
flags when creating a Font (e.g., Bold, Italic, Strikeout, Underline).

A simpler approach to displaying formatted text is to use the RichTextBox
control with RTF or the WebBrowser control (2.0 framework) with HTML.
 

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

Back
Top