Asp.net 如何设置复选框列表属性?

Asp.net 如何设置复选框列表属性?,asp.net,checkbox,width,Asp.net,Checkbox,Width,我有一个大约有50个值的复选框列表。但我只想显示5个,并使用滚动条导航其他人 我试着用 <asp:CheckBoxList CheckBoxes="true" Width="250px" Height="120px" RepeatColumns="5" RepeatDirection="Vertical" RepeatLayout="Flow" runat="server" SelectionMode="Multiple" /&g

我有一个大约有50个值的复选框列表。但我只想显示5个,并使用滚动条导航其他人

我试着用

<asp:CheckBoxList CheckBoxes="true" Width="250px" Height="120px"  RepeatColumns="5" RepeatDirection="Vertical" RepeatLayout="Flow" 
                            runat="server" SelectionMode="Multiple" />
我希望是这样

[] Value1
[] Value2 ...

您需要更改行
Width=“250px”Height=“120px”
,使其不那么宽,然后复选框将逐行显示,具体取决于您选择的宽度

您可能希望将RepeatColumns设置为0,因为这将导致它使用Verical align属性,而不是水平平铺它们


如果您想让它们仅显示5,并使用滚动条来处理超过5的任何内容,则需要设置高度,使其仅显示最初的5,然后添加:

overflow: auto;

切换到复选框,以便强制控件边界之外的任何内容滚动。请记住,控件还需要是块元素而不是内联的。

我认为您只需要为
复选框列表设置一个固定大小的容器,将其
溢出
样式设置为
滚动

<div style="width:250px; height:120px; overflow:scroll;">
  <asp:CheckBoxList CheckBoxes="true" Width="250px" RepeatColumns="1" 
    RepeatDirection="Vertical" RepeatLayout="Flow" 
    runat="server" SelectionMode="Multiple" />
</div>

是否使用滚动条?水平还是垂直?
<div style="width:250px; height:120px; overflow:scroll;">
  <asp:CheckBoxList CheckBoxes="true" Width="250px" RepeatColumns="1" 
    RepeatDirection="Vertical" RepeatLayout="Flow" 
    runat="server" SelectionMode="Multiple" />
</div>