Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. String Formatting when Printing

String Formatting when Printing

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bfoo75
    wrote on last edited by
    #1

    Hi everyone, I'm running into a problem while trying to format strings for printing. I'm working heavily with finance and I need the values to be flushed right and formatted as cash. Unfortunately none of the values are being formatted correctly. I assumed that if the String.Format() function was used correctly that the string would be returned with all the information needed to line it up correctly. I ran into a similar problem when trying to line up information in combo boxes. What I think is going on is that the width of a space is much smaller then the width of the characters in a font. Does anyone know of a workaround for this? Thanks. - Will

    L 1 Reply Last reply
    0
    • B bfoo75

      Hi everyone, I'm running into a problem while trying to format strings for printing. I'm working heavily with finance and I need the values to be flushed right and formatted as cash. Unfortunately none of the values are being formatted correctly. I assumed that if the String.Format() function was used correctly that the string would be returned with all the information needed to line it up correctly. I ran into a similar problem when trying to line up information in combo boxes. What I think is going on is that the width of a space is much smaller then the width of the characters in a font. Does anyone know of a workaround for this? Thanks. - Will

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Sure, the easy way out is to display/print (parts of) the text using a so called "non-proportional" font; such font has all characters (including the space char) with the same width. An example is "Courier New". :)

      Luc Pattyn [My Articles] [Forum Guidelines]

      B 1 Reply Last reply
      0
      • L Luc Pattyn

        Sure, the easy way out is to display/print (parts of) the text using a so called "non-proportional" font; such font has all characters (including the space char) with the same width. An example is "Courier New". :)

        Luc Pattyn [My Articles] [Forum Guidelines]

        B Offline
        B Offline
        bfoo75
        wrote on last edited by
        #3

        Thanks Luc, That did the trick. I was trying to use system before because I thought it was lined up, but courier worked beautifully.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups