By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

String.PadRight() function not working in combobox

100+
P: 153
Refer the pic below, It's showing properly when seen in notepad but not in combobox.

Here is the code

Expand|Select|Wrap|Line Numbers
  1.  
  2. OleDbDataReader trunkdr = trunkcom.ExecuteReader();
  3. while (trunkdr.Read())
  4. {
  5. cmbtrunks.Items.Add(trunkdr["trunk_virtual_number"].ToString().ToUpper().PadRight(15,' ') + trunkdr["trunk_name"].ToString().ToUpper().PadRight(15,' ') + trunkdr["trunk_connected_trunk"].ToString().ToUpper().PadRight(15,' '));
  6. }
  7.  

Jan 30 '09 #1
Share this Question
Share on Google+
2 Replies


vekipeki
Expert 100+
P: 229
The difference is that Notepad is using a fixed-width font (e.g. Courier New). Your app is using MS Sans Serif by default. Compare the width of "I" and the width of "W" in Notepad and in your app.

You can change your ComboBox.Font property to a fixed-width font, or you can try to use a multi-column combo box (try Googling it).

Here are some Multi-column combo examples:
http://www.codeproject.com/KB/combob...lumncombo.aspx
http://www.codeproject.com/KB/archit...FlatCombo.aspx
Jan 30 '09 #2

100+
P: 153
Thanks vekipeki !

I used a monospaced font and it worked. :)
Feb 2 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.