Results 1 to 2 of 2

Thread: [2.0] Static Length Strings / Aligning text

  1. #1

    Thread Starter
    Member MasterEvilAce's Avatar
    Join Date
    Jul 2002
    Posts
    60

    [2.0] Static Length Strings / Aligning text

    I'm wanting to align text in a textbox, in columns. I'm using courier new, so every character is equal in width. the easiest way of doing this I imagine is to set my strings to specific-width somehow. If a string is say, less than 20 characters, then fill it with spaces.

    Using tabs is also doable, as well.. but requires a bit more work in predicting how many tabs you need to align the data.

    i also read somewhere you can set tabstops in a textbox, but i'm not looking for that, as the tabs aren't always going to be in the same area.

    The first method i mentioned is probably what i'm looking to do unless there is an easier way. How would i go about doing that?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Static Length Strings / Aligning text

    Use the String.PadLeft method. You specify the total number of characters and it will add spaces to achieve that length if required.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width