Solved

Display Multiple Lines In ListBox Control

Posted on 2007-12-02
3
1,077 Views
Last Modified: 2013-11-26
I'm using ASP.NET 2.0.  Is there a way to make a listbox display multiple lines (wrapped) within a row?  Also, is there a way to set the background color of a specific row?

Thanks
0
Comment
Question by:Ray Turner
  • 2
3 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20393925
0
 
LVL 21

Accepted Solution

by:
surajguptha earned 250 total points
ID: 20393932
oops.. I meant giving you this link
http://www.codeproject.com/aspnet/ColorListBox.asp
0
 
LVL 6

Assisted Solution

by:CasUK
CasUK earned 250 total points
ID: 20394063
If you're using ASP - then you're probably writing a webpage.

The problem you have is that I'm not aware of a way to create multi-line listboxes without the resorting to Javascript in pages (which would lead to other problems anyway)

I would probaby use the OPTGROUP tag to group the different lines. Use the same value for each subsequent line in the group so that it can be selected.

As for colouring them, some basic CSS would do the trick - I've put some inline CSS in the code to keep it simple.

Although you can still only select one line at a time, the illusion of a multiline box is there. I hope this helps.
<select size="6">
<optgroup label="John Doe" style="background-color:red; color=white;">
<option value ="johndoe">123 My Road</option>
<option value ="johndoe">My Town</option>
</optgroup>
<optgroup label="Jane Doe" style="background-color:yellow; color:blue;">
<option value ="janedoe">456 My Road</option>
<option value ="janedoe">My Town</option>
</optgroup>
</select>

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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