Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

no character alignment when adding 2 fields together in a dropdownlist

Posted on 2012-03-22
8
Medium Priority
?
189 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

705 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