Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdownlist with 2 colums

Status
Not open for further replies.

IlseDC

Programmer
Mar 24, 2003
49
BE
On my webform I have a dropdownlist.
In this dropdownlist I want to display ID and description.
In my datasource I made a field ID_Description:
ID_Description = ID.trim() + " " + Description.trim();
I used this field as DataTextField in the dropdownlist.
Problem: ID and Description have not the same alignment for all items because the length of ID is not the same for all records. I don't want to use a fixed font.
So I want to display ID and Description in two colums in the dropdownlist.
Is this possible?

Thanks.
Ilse
 
It isn't possible with the standard drop down list (although it could be extended to do so but that would involve a fair amount of work). The other options you have are:

1) Use a 3rd party control (there are quite a few that offer that functionality).
2) Pad the id so that they are all of equal length


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Padding the id is not a good option when you use a non-fixed font (Arial, Verdana, ...).
When you pad the id you have to use a fixed font (Courier).
A fixed font is also needed because f.e. character W is larger than I.
But I don't like fixed fonts.
 
If you don't like fixed width fonts, you may have to go with a 3rd party control.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
hi

why don't you just create a function which fills up with spaces , let's say (max - ID.length)x(spaces) + Description
, where max= 20 (or 30..)

int max=30;
string tmp = ID;
for (int i = 0;i<(max-id.length);i++)
tmp+=" ";

tmp+=Description;

 
To fill up with spaces works only if you use a fixed width font (courier).
In proportional font (arial) the characters don't have the same width so the alignment of description will not be the same for all items.
I would like to have two columns but with a proportianal font not a fixed width font.
 
3rd party control then...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top