简体   繁体   English

ListBox Web控件属性

[英]ListBox web control attributes

The Windows Forms "edition" of a ListBox has an attribute called ScrollAlwaysVisible . ListBox的Windows窗体“版本”具有一个名为ScrollAlwaysVisible的属性。 It removes the scroll-bar from the control easily. 它可以轻松地从控件中删除滚动条。

Is there something I can to do achieve the same in the asp control for webforms? 在webform的asp控件中,我可以做些什么来达到相同的目的吗? I am setting the line count of the box to the same as a list data, therefore have no need for the scroll-bar. 我将框的行数设置为与列表数据相同,因此不需要滚动条。 It looks terribly ugly. 看起来很难看。

Setting the rows of the listbox, by request: 根据要求设置列表框的行:

List<string> boxList = new List<string>()
ListBox<string> newBox = new ListBox<string>();
void someVoid()
{
    int count = boxList.Count;
    ListBox.Rows = count;
}

You can directly use css to make scrollbar always visible, like this. 您可以像这样直接使用css使滚动条始终可见。

<asp:ListBox ID="lst" runat="server" style="overflow-y:visible;"></asp:ListBox>

Note: this will display vertical scroll bar always, if you want to have both horizontal and vertical then use overflow:visible . 注意:这将始终显示垂直滚动条,如果要同时具有水平和垂直方向,请使用overflow:visible

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM