Bruno
Bruno

Reputation: 6469

VB.NET Create two column CheckboxList

My below code pulls in 100 items into the checkboxlist all into one column. How can I modify the code so it will appear as two columns? Thanks!

    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

Upvotes: 8

Views: 10258

Answers (2)

James Johnson
James Johnson

Reputation: 46077

Use RepeatDirection, RepeatColumns, and RepeatLayout:

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

Upvotes: 1

geekchic
geekchic

Reputation: 1566

Try something like:

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

Upvotes: 18

Related Questions