VB.NET创建两列CheckboxList

时间:2011-10-19 15:20:50

标签: asp.net vb.net

我的下面的代码将100个项目全部放入一个列的复选框列表中。 如何修改代码以使其显示为两列?谢谢!

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        Dim di As New IO.DirectoryInfo(ImagePath)
        Dim imageArray As IO.FileInfo() = di.GetFiles()
        Dim image As IO.FileInfo

        'list the names of all images in the specified directory

        For Each image In imageArray.OrderBy(Function(i) i.Name)
            CheckBoxList1.Items.Add(image.Name)
        Next
    End If
End Sub

2 个答案:

答案 0 :(得分:17)

尝试类似:

<asp:checkboxlist id="CheckBoxList1" runat="server" RepeatLayout="table" RepeatColumns="2" RepeatDirection="vertical"/>

答案 1 :(得分:1)

使用RepeatDirectionRepeatColumnsRepeatLayout

<asp:CheckBoxList RepeatDirection="Horizontal" RepeatColumns="2" RepeatLayout="Table" ...>