Add horizontal Scroll bar to a Server Control Listbox or DropDownL

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Thanks for the reply Craig .But if you can elaborate more on the solution it
would be great.

Regards
Vidds
 
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.
 
Back
Top