Solved

no character alignment when adding 2 fields together in a dropdownlist

Posted on 2012-03-22
8
177 Views
Last Modified: 2012-04-07
I know the questions does not make sense but I need a quick answer.

I am populating the dropdownlist wanting to lay out the result nicely.

  var context = new dbHCAEntities();

             var codes = from a in context.subPrem
                           group a by new {a.stdcode, a.pstd_desc} into mygroup
                           select new { stdcode = mygroup.Key.stdcode , mygroup.Key.pstd_desc };

             foreach (var item in codes)
             {
                 cbPremium.Items.Add(item.stdcode + "     " + item.pstd_desc );
                 cbPremiumPen.Items.Add(item.stdcode + "     " + item.pstd_desc );
             }

Open in new window


I would like it to show
CA      1 Parent Family: 0-45    
CB      1 Parent Family: 46-60  
CC      1 Parent Family: 61-65  
CD      1 Parent Family: 66-99  
FA      2 Parent Family: 0-45    
FB      2 Parent Family: 46-60  
FC      2 Parent Family: 61-65  
FD      2 Parent Family: 66-99  
MA      Member: 0-45            
MB      Member: 46-60            
MC      Member: 61-65            
MD      Member: 66-99            
PA      Couple: 0-45            
PB      Couple: 46-60            
PC      Couple: 61-65            
PD      Couple: 66-99            

where everything is lined up nicely.

However my result is

CA    1 Parent Family: 0-45    
CB    1 Parent Family: 46-60  
CC    1 Parent Family: 61-65  
CD    1 Parent Family: 66-99  
FA    2 Parent Family: 0-45    
FB    2 Parent Family: 46-60  
FC    2 Parent Family: 61-65  
FD    2 Parent Family: 66-99  
MA    Member: 0-45            
MB    Member: 46-60            
MC    Member: 61-65            
MD    Member: 66-99            
PA    Couple: 0-45            
PB    Couple: 46-60            
PC    Couple: 61-65            
PD    Couple: 66-99  

because I had to space it using 4 spaces. See image as well.

How can I space the result nicely in the dropdown list?

Thanks.
spacing.jpg
0
Comment
Question by:elmbrook
  • 3
  • 3
  • 2
8 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 37755616
Are you using a monospace font?
0
 

Author Comment

by:elmbrook
ID: 37755629
Font = Verdana 8pt.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 37755651
Verdana is not a monspace font, so you will have issues trying to align the text exactly. You can get close, but it won't be exact. Only a monospace font would line up properly since each character takes up the same amount of horizontal space.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37755825
use courier, Arial font
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 37755836
I don't believe Arial is a monospace font.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37755841
my mistake, use courier, here is complete list:-
http://en.wikipedia.org/wiki/List_of_Microsoft_Windows_fonts
0
 

Accepted Solution

by:
elmbrook earned 0 total points
ID: 37763385
Thanks for all the feedback but I was hoping on a solution that allowed me to put a 'tab' in the display of the drodownlist rather than changing fonts.

My application at this stage has about 30 forms already and I am only a short way through developing it.

I don't want to change fonts. I would live with it rather than change the fonts.
0
 

Author Closing Comment

by:elmbrook
ID: 37818726
No usable solutions
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now