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 151901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:31:39+00:00 2026-05-11T09:31:39+00:00

I’m trying to create coloumns of text for a C# app that will be

  • 0

I’m trying to create coloumns of text for a C# app that will be running on MSN Messenger. I’m having trouple getting everything to line up.

Here’s an example of the output that I want:

1)  Pizza Hut                                            123 Fake St. 2)  Domino's Pizza                                       123 Fake St. 3)  The Cheesecake Cafe                                  123 Fake St. 4)  Capital Pizza & Steakhouse                           123 Fake St. 5)  Funky Pickle Pizza                                   123 Fake St. 6)  Boston Pizza                                         123 Fake St. 7)  Rose Bowl Rouge Lounge                               123 Fake St. 8)  Royal Pizza                                          123 Fake St. 9)  A Columbus Pizza & Donair Inc                        123 Fake St. 

But because it is a variable width font it is displaying like this:

1)  Pizza Hut                                        123 Fake St. 2)  Domino's Pizza                                   123 Fake St. 3)  The Cheesecake Cafe                                  123 Fake St. 4)  Capital Pizza & Steakhouse                               123 Fake St. 5)  Funky Pickle Pizza                                   123 Fake St. 6)  Boston Pizza                                     123 Fake St. 7)  Rose Bowl Rouge Lounge                               123 Fake St. 8)  Royal Pizza                                          123 Fake St. 9)  A Columbus Pizza & Donair Inc                    123 Fake St. 

I have tried using the C# string.PadRight() function as well as creating my own function that add padding using spaces and tabs. Both work fine with fixed width fonts but break with variable width fonts.

Is there any way to determine the width of a string in a given font?

Or does anyone have any other suggestions?

  • 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. 2026-05-11T09:31:40+00:00Added an answer on May 11, 2026 at 9:31 am

    Just use the TextRenderer class. The simplest case :

    Size size = TextRenderer.MeasureText('Hello world', someFont); 

    If you don’t have access to System.Windows.Fonts Graphics.MeasureString remains, it have some limitations but should do the work :

    Bitmap bmp = new Bitmap(1,1); Graphics graphics = Graphics.FromImage(bmp); SizeF size = graphics.MeasureString('Hello world', someFont); 

    But be aware that if the font of your text and the spaces MUST be the same there will be cases where you can’t align the text perfectly. I don’t know what MSN Messenger is able to do in your case but except if you have access to at least a subset of HTML you won’t have a perfect output.

    You should also be aware that if you do measurements on a local computer and send to another without the correct font installed your columns won’t look like columns anymore so your are limited to the basic subset of fonts presents on all computers.

    If multiple operating system support is also a requirement you will have some big problems as the Arial font on Mac and PCs doesn’t look (and measure) exactly the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.