So I have recently come across string.Format("{0, x}", "Word") for aligning strings, with demonstration code that works fine in the CMD.

Does this also function correctly when pumping text to a label? I am finding that it does not behave as expected and instead misaligns the text.

Using an example I nicked off a site

Console.WriteLine("-------------------------------");
Console.WriteLine("First Name | Last Name  |   Age");
Console.WriteLine("-------------------------------");
Console.WriteLine(String.Format("{0,-10} | {1,-10} | {2,5}", "Bill", "Gates", 51));
Console.WriteLine(String.Format("{0,-10} | {1,-10} | {2,5}", "Edna", "Parker", 114));
Console.WriteLine(String.Format("{0,-10} | {1,-10} | {2,5}", "Johnny", "Depp", 44));
Console.WriteLine("-------------------------------");

Is shown to work fine in console however if you look at it within debugging or on a label its completely misaligned.

Are there any alternatives short of using /t to align or building everything up with strings, pad them and then append them onto the string builder I am using?

It would only work with a label if you have set a fixed width font.

Aha shall try that and report back

and Prit takes the gold star once again... now to find a fixed width font that looks pretty...

courier?

Good shout, it's Courier New though for monospacing

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.