Why is not the columns aligned

  • Thread starter Thread starter Tony
  • Start date Start date
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
 
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
 
Back
Top