Add horizontal Scroll bar to a Server Control Listbox or DropDownL

G

Guest

Hi Everyone,

How come Server listbox control does not have a Horizontal Scroll Property?
If any one has an idea how we add a Horizontal scroll to a listbox or
dropdown list box it would be quite helpful.Thanks in advance

Regards
Vidds
 
C

Craig Deelsnyder

Vidds said:
Hi Everyone,

How come Server listbox control does not have a Horizontal Scroll Property?
If any one has an idea how we add a Horizontal scroll to a listbox or
dropdown list box it would be quite helpful.Thanks in advance

Regards
Vidds

It's more than likely because the HTML SELECT control does not have that
capability (which is what ListBox renders to).

If you really, really need it, one idea would be to create a custom
ListBox class whose HTML looks like this: sets the width of the SELECT
to that of your widest value's width (the max width of the scrollbar,
for example). Now wrap that SELECT inside of a DIV of the 'constrained'
size and let it scroll on overflow.
 
G

Guest

Thanks for the reply Craig .But if you can elaborate more on the solution it
would be great.

Regards
Vidds
 
C

Craig Deelsnyder

Vidds said:
Thanks for the reply Craig .But if you can elaborate more on the solution it
would be great.

Regards
Vidds

Here's a quick example starting down those lines, here's the type of
HTML you want spit out by a control:

<div style="width:200px; height:100px; overflow:auto;">
<SELECT size="4">
<OPTION
Value="1">blahblahblahblahblahblahblahblahblahblahblahblah</OPTION>
<OPTION Value="2">2</OPTION>
<OPTION Value="3">3</OPTION>
<OPTION Value="4">4</OPTION>
</SELECT>
</div>

so in essence I'd recommend creating a composite custom control for
this, which renders this HTML. They're pretty easy to make, Google on
the terms 'composite control asp.net'.

The toughest part will be matching up the div dimensions to that of the
select box, to make the scrollbars work/line up properly. That's why
it's kinda tricky.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top