Solved

Display Multiple Lines In ListBox Control

Posted on 2007-12-02
3
1,074 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
Comment Utility
0
 
LVL 21

Accepted Solution

by:
surajguptha earned 250 total points
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now