Hi,
I am working with ListView. How can a ListView have multiple columns and also have CheckBox at the same time? (preferably in its View property set as "Report")

Recommended Answers

All 7 Replies

To enable check boxes:
When you have added a list view control to your form, right click any where on list view control and select general tab in property pages.
1) Enable check box named "Checkboxes"
2) Select "3-Report" in view property.

To have multiple check boxes select "Column Headers" tab in property pages and add columns using "Insert Column" Button and text in the Text property simultaneously, you can add or remove columns later at run time through code also.

The following example shows how to add ColumnHeaders and several ListItem objects with subitems to a ListView control.

Private Sub Form_Load()
   Dim clmX As ColumnHeader
   Dim itmX As ListItem
   Dim i As Integer

   For i = 1 To 3
      Set clmX = ListView1.ColumnHeaders.Add()
      clmX.Text = "Col" & i
   Next i
   
   ' Add 10 items to list, all with the same icon

   For i = 1 To 10
      Set itmX = ListView1.ListItems.Add()
      itmX.SmallIcon = 1
      itmX.Text = "ListItem " & i
      itmX.SubItems(1) = "Subitem 1"
      itmX.SubItems(2) = "Subitem 2"
   Next i
End Sub

Hope this will help you.

Checkboxes can also be set programmatically - ListView1.Checkboxes = True/False

Thanks vipin saxena,
I have been trying on this, now i understand where i had missed.

Thanks !

Is it possible to get more then one column of checkboxes? I know the setting ListView1.Checkboxes = True/False. But then the checkboxes are only in the first column.

I created a ListView, but now the ListItems in the ListView is editable, but I want to lock the editing for the ListView.
How is that possible?

pls can someone help me, i wanted my data report to appear in landscape while designing

dear jullierock,
Post your problem as a new thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.