שתף באמצעות


multicolumn checked list box in vb.net

Question

Wednesday, October 23, 2013 4:14 AM

How to add multi columns to checked listbox in visual studio 2005.

And how to read multiple columns ?

h4007

All replies (4)

Wednesday, October 23, 2013 4:42 AM ✅Answered | 1 vote

How to add multi columns to checked listbox in visual studio 2005.

You could use a ListView with the CheckBoxes property set to True.   The following example code populates a ListView with information from files in a folder.

    For Each FileName As String In Directory.GetFiles(sFol, "*.*")

        Dim FInfo As FileInfo = New FileInfo(FileName)
            lvi = New ListViewItem(FInfo.Name)
            ' Load ListBox
            ListView1.Items.Add(lvi)
            lvi.SubItems.Add(sFol)
            lvi.SubItems.Add(FInfo.Length.ToString)
            lvi.SubItems.Add(FInfo.CreationTime.ToString)
        End If
    Next FileName

Wednesday, October 23, 2013 4:53 AM

so basically by setting checked listbox multicolumn property to true, won't work as though there are 2 columns, right ??

h4007


Wednesday, October 23, 2013 6:07 AM

so basically by setting checked listbox multicolumn property to true, won't work as though there are 2 columns, right ?

Setting a checked list box Multicolumn property to True will display as many columns as are needed (or can be fitted) for the list items, using horizontal scrolling to view additional columns.  If that's what you want to do then you need to explain exactly what problem you are having when you try to do that. 
http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.multicolumn(v=vs.110).aspx

But if you want one list where each item in the list needs two or more columns in which to display its data, then use the example, I provided.


Thursday, October 24, 2013 7:54 AM

Oh ok..

I misunderstood the multi column property.

Checked listbox multiple columns means only one column for each item but if list does not fit in size the it will add 2nd column.

h4007