Gabriel Chung
Gabriel Chung

Reputation: 1577

ASP.NET: How to hide ListBox control vertical scrollbar?

I have tried CSS: overflow: auto. It doesn't work. Any way to achieve it?

Do I need to create my custom control as I have seen it on ASP.NET forum?

Upvotes: 0

Views: 18134

Answers (5)

Eduardo Cuomo
Eduardo Cuomo

Reputation: 18937

Using jQuery:

<asp:ListBox
    ClientSideEvents-Init="function(s,e){$(s.GetMainElement()).find('div:first').css('overflow','hidden');}"
    ... />

Upvotes: 0

mayur
mayur

Reputation: 11

this work for me

listBox1.DataSource = ....
listBox1.DataBind();
listBox1.Rows = listBox1.Items.Count + 1;

.

<div Class="divBorderCSS">
    <asp:listbox id="lbPCList" runat="server" DataTextField="Text" DataValueField="Value" selectionmode="Multiple" CssClass="lbCSS">
    </asp:listbox>

.

.listboxCSS
{
    font-size: 8pt;
    font-family: Arial;
    border:0;
    overflow:auto;
}

.divBorderCSS
{
    border-left-width:thin;
    border-right-width: thin;
    border-top:thin;
    border-bottom: thin;
    border-color: #7F9DB9;
    border-style:solid;
    overflow:auto;
    width: 300px;
    height: 100px;
    POSITION: relative;
}

Upvotes: 1

Liero
Liero

Reputation: 27348

this should work:

listBox1.Rows = listBox1.Items.Count;

it causes all items are visible is SELECT html tag. You can place it to your own div set overflow and make your own scrollbars if you want.

Upvotes: 1

craigmoliver
craigmoliver

Reputation: 6562

Try this control from the AJAX Control Toolkit..

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/DropDown/DropDown.aspx

Upvotes: 0

Eppz
Eppz

Reputation: 3206

I would go with creating a custom control like you mentioned.

What is your desired goal? Creating your own scrollbar to put in the listbox?

Upvotes: 1

Related Questions