Solved

no character alignment when adding 2 fields together in a dropdownlist

Posted on 2012-03-22
8
184 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 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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!
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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