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 class handling.... aligment etc...

string class handling.... aligment etc...

Scheduled Pinned Locked Moved C#
csharptutorial
2 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.
  • A Offline
    A Offline
    Arish rivlin
    wrote on last edited by
    #1

    hi. I need to concut a string in C# so that it will be aligned to the left. for example: dd/mm/yyy message1 line dd/mm/yyy message222 line dd/mm/yyy message566455 line etc... note: it's not possible here but the intention was for all the "line"s to be one on top of the other.... Thanks....

    L 1 Reply Last reply
    0
    • A Arish rivlin

      hi. I need to concut a string in C# so that it will be aligned to the left. for example: dd/mm/yyy message1 line dd/mm/yyy message222 line dd/mm/yyy message566455 line etc... note: it's not possible here but the intention was for all the "line"s to be one on top of the other.... Thanks....

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

      :confused: strings are aligned to the left (at least if you write from left to right). if you are painting to the screen, it may help to choose a "non-proportional" font, such as "Courier New" so all characters have the same width; maybe you want a DateTime format that applies leading zeroes, and you might show your message number using a fixed number of digits: num.ToString("000000") will generate at least 6 characters, using leading zeroes. If you are painting on a Graphics, you can use MeasureString() to get the string width in pixels, and adjust coordinates accordingly (but that would be useful only if you do NOT want to align to the left). Hope this helps. :)

      Luc Pattyn [My Articles] [Forum Guidelines]

      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