Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8384761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:29:22+00:00 2026-06-09T17:29:22+00:00

I am just too confused when it comes to white space. I am trying

  • 0

I am just too confused when it comes to white space. I am trying to padright a string and it won’t cooperate with me.

I want to print a datagridview and so I have columns header and below it the actual rows. No matter how I try to determine the exact length or width to pad the string, it is either too short or too long. So, I can’t align the values with the column headers before I send to the printer.

if I just do the following for instance:

thestring := '.NET is cool';
thestring := thestring.padright(100); //thestring = too short = '.NET is cool    '

if I do this:

var tmpstr := '=';
tmpstr := tmpstr.PadRight(15); //total length of characters is 15
var swidth := int32(ev.Graphics.Measurestring(tmpstr,new Font('Arial',9)).Width);

thestring := '.NET is cool';
thestring := theString.padright(swidth); //thestring = too long = '.NET is cool   

                '

PadRight or PadLeft seems to work correctly when you pass in actual character not white space, but I could be wrong.

Any input or help will be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:29:23+00:00Added an answer on June 9, 2026 at 5:29 pm

    There is a difference between each character width when using a proportional font. Arial is a proportional font as are most of the fonts we normally use.

    Wikipedia: Typeface

    A proportional typeface contains glyphs of varying widths, while a
    monospaced (non-proportional or fixed-width) typeface uses a single
    standard width for all glyphs in the font.

    What that means is every letter could be a different with. A space does have a width but it will not necessary be the same as the letter “i” or the letter “w”.

    There are really two options:

    1. You can use a monospace font like Courier New. That will let you use spaces to line up characters based on the letter count.
    2. Use pixel alignments. In that case you need to measure your text width and move the starting location of the text out command so that items line up under each other. You actually calculate the white space that you need and then move to that location instead of padding the string.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just not too sure the proper way of doing this. I basically have
I've heard before that modules are just classes too. I have a few situations,
I just spent way too long trying to diagnose why, in the following snippet
I have code blindness, it's like snowblindness, just wth far too much code. I
Hopefully this question won't be too convoluted or vague. I know what I want
OK, I have a question I'm too confused to ask properly but here's a
I think I have just been working too long and am tired. I have
Probably I'm just too dump for googling, but I always thought char arrays get
Maybe it's just too early but I can' figure out why I can't get
The following code seems to be just too much, for getting a single count

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.