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

故事扮演 提交于 2019-12-01 14:57:58

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?

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.

mayur

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;
}

Try this control from the AJAX Control Toolkit..

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

Using jQuery:

<asp:ListBox
    ClientSideEvents-Init="function(s,e){$(s.GetMainElement()).find('div:first').css('overflow','hidden');}"
    ... />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!