Solved

no character alignment when adding 2 fields together in a dropdownlist

Posted on 2012-03-22
8
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 75

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 75

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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37755825
use courier, Arial font
0
 
LVL 75

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 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