Solved

no character alignment when adding 2 fields together in a dropdownlist

Posted on 2012-03-22
8
183 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
detecting  the added row index in a datagridview 3 70
Wav problem 4 25
What is "public object" in C#? 3 45
Adding  DYMO Labelprinter to c# client application 4 28
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

815 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

11 Experts available now in Live!

Get 1:1 Help Now