How do you print bold and underline using drawstring?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Siv

    How do you print bold and underline using drawstring?

    Hi,
    I want to print using the Graphics.Drawst ring method but instead of using
    either bold or underline I want to combine both so the printed text is bold
    and underline??

    The way I send the drawstring command is as follows:

    Somewhere in my declarations I have:
    Private ra As System.Drawing. StringFormat

    Private fb As New System.Drawing. Font("Courier New", 10,
    FontStyle.Bold, GraphicsUnit.Po int)
    Private fu As New System.Drawing. Font("Courier New", 10,
    FontStyle.Under line, GraphicsUnit.Po int)

    and in the printing code I have:

    ra = New StringFormat

    ra.Alignment = StringAlignment .Far 'Right alignment in a left to
    right environment

    e.Graphics.Draw String("Some text right aligned with underlining",
    fu, Brushes.Black, x, y, ra)

    If I want to do the same but also simultaneously have the text underlined
    and emboldened, how do I achieve that??

    Any examples greatly appreciated.

    Siv

  • Patrice

    #2
    Re: How do you print bold and underline using drawstring?

    You can combine styles by using "Or" : FontStyle.Bold Or
    FontStyle.Under line.

    This is generally mentionned in the doc by "This enumeration has a
    FlagsAttribute attribute that allows a bitwise combination of its member
    values."

    --
    Patrice

    "Siv" <g@removethiste xtsivill.coma écrit dans le message de news:
    1210ED7B-74FC-4AA6-AC79-D59E07D04C77@mi crosoft.com...
    Hi,
    I want to print using the Graphics.Drawst ring method but instead of using
    either bold or underline I want to combine both so the printed text is
    bold and underline??
    >
    The way I send the drawstring command is as follows:
    >
    Somewhere in my declarations I have:
    Private ra As System.Drawing. StringFormat
    >
    Private fb As New System.Drawing. Font("Courier New", 10,
    FontStyle.Bold, GraphicsUnit.Po int)
    Private fu As New System.Drawing. Font("Courier New", 10,
    FontStyle.Under line, GraphicsUnit.Po int)
    >
    and in the printing code I have:
    >
    ra = New StringFormat
    >
    ra.Alignment = StringAlignment .Far 'Right alignment in a left to
    right environment
    >
    e.Graphics.Draw String("Some text right aligned with underlining",
    fu, Brushes.Black, x, y, ra)
    >
    If I want to do the same but also simultaneously have the text underlined
    and emboldened, how do I achieve that??
    >
    Any examples greatly appreciated.
    >
    Siv

    Comment

    • Siv

      #3
      Re: How do you print bold and underline using drawstring?

      Patrice,
      I guessed it had to be something like that, thanks, I'll give that a go.

      Siv

      "Patrice" <http://www.chez.com/scribe/wrote in message
      news:uQfuTSYbIH A.3932@TK2MSFTN GP05.phx.gbl...
      You can combine styles by using "Or" : FontStyle.Bold Or
      FontStyle.Under line.
      >
      This is generally mentionned in the doc by "This enumeration has a
      FlagsAttribute attribute that allows a bitwise combination of its member
      values."
      >
      --
      Patrice
      >
      "Siv" <g@removethiste xtsivill.coma écrit dans le message de news:
      1210ED7B-74FC-4AA6-AC79-D59E07D04C77@mi crosoft.com...
      >Hi,
      >I want to print using the Graphics.Drawst ring method but instead of using
      >either bold or underline I want to combine both so the printed text is
      >bold and underline??
      >>
      >The way I send the drawstring command is as follows:
      >>
      >Somewhere in my declarations I have:
      > Private ra As System.Drawing. StringFormat
      >>
      > Private fb As New System.Drawing. Font("Courier New", 10,
      >FontStyle.Bold , GraphicsUnit.Po int)
      > Private fu As New System.Drawing. Font("Courier New", 10,
      >FontStyle.Unde rline, GraphicsUnit.Po int)
      >>
      >and in the printing code I have:
      >>
      > ra = New StringFormat
      >>
      > ra.Alignment = StringAlignment .Far 'Right alignment in a left to
      >right environment
      >>
      > e.Graphics.Draw String("Some text right aligned with underlining",
      >fu, Brushes.Black, x, y, ra)
      >>
      >If I want to do the same but also simultaneously have the text underlined
      >and emboldened, how do I achieve that??
      >>
      >Any examples greatly appreciated.
      >>
      >Siv
      >
      >

      Comment

      Working...