Why is not the columns aligned

T

Tony

Here I add three concatenated strings to a combobox.
As you can see a use PadRight so the columns should be aligned verically.
But this doesn't work the columns is not aligned in vertical.
I can't understand why is not work to use PadRight

datum = "2013-05-06";
prannr = "619".PadRight(8);
skiftbeskr = "DayTime".PadRight(15);
loopnrDag = "2".PadRight(5);
rad = datum + " | " + prannr + " | " + skiftbeskr + " | " +
loopnrDag;
this.listAllSkift.Items.Add(rad);

datum = "2013-05-06";
prannr = "619".PadRight(8);
skiftbeskr = "DayTime".PadRight(15);
loopnrDag = "3".PadRight(5);
rad = datum + " | " + prannr + " | " + skiftbeskr + " | " +
loopnrDag;
this.listAllSkift.Items.Add(rad);

datum = "2013-05-06";
prannr = "0".PadRight(8);
skiftbeskr = "DayTime".PadRight(15);
loopnrDag = "3".PadRight(5);
rad = datum + " | " + prannr + " | " + skiftbeskr + " | " +
loopnrDag;
this.listAllSkift.Items.Add(rad);

//Tony
 
A

Anders Eriksson

Here I add three concatenated strings to a combobox.
As you can see a use PadRight so the columns should be aligned verically.
But this doesn't work the columns is not aligned in vertical.
I can't understand why is not work to use PadRight

datum = "2013-05-06";
prannr = "619".PadRight(8);
skiftbeskr = "DayTime".PadRight(15);
loopnrDag = "2".PadRight(5);
rad = datum + " | " + prannr + " | " + skiftbeskr + " | "
+ loopnrDag;
this.listAllSkift.Items.Add(rad);

datum = "2013-05-06";
prannr = "619".PadRight(8);
skiftbeskr = "DayTime".PadRight(15);
loopnrDag = "3".PadRight(5);
rad = datum + " | " + prannr + " | " + skiftbeskr + " | "
+ loopnrDag;
this.listAllSkift.Items.Add(rad);

datum = "2013-05-06";
prannr = "0".PadRight(8);
skiftbeskr = "DayTime".PadRight(15);
loopnrDag = "3".PadRight(5);
rad = datum + " | " + prannr + " | " + skiftbeskr + " | "
+ loopnrDag;
this.listAllSkift.Items.Add(rad);

//Tony

You don't specify if you're using Winform, WPF, ...

But, either you need to use a fixed-width font (e.g. Courier New) or
use a multi-column combobox.

Here is one winform sample of a multi-column combobox
http://www.codeproject.com/Articles/3206/Multi-Column-ComboBox

// Anders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top