Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Display Multiple Lines In ListBox Control

Posted on 2007-12-02
3
Medium Priority
?
1,083 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 1000 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 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline

927 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