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

x
?
Solved

Display Multiple Lines In ListBox Control

Posted on 2007-12-02
3
Medium Priority
?
1,082 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
[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
  • 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 benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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