Can I create a column in the listview's report mode in which every time I add another line, this column will have a checkbox and they will be arrayed according to line?
I.E:
If i have 3 columns, and I add to the fist and second one the text:
"col1","col2"
The code will add a check box instead of text to the line of column three
Last edited by Blacknight; Oct 17th, 2004 at 06:21 PM.
You can only have the first column of a listview to contain a checkbox
although you can fake it. Change the positioning so the first
columns position is in the place you want the checkboxes to be...
VB Code:
Option Explicit
Private Sub Form_Load()
'Setup the lvw
ListView1.Checkboxes = True
ListView1.ColumnHeaders.Add , , "Col 1"
ListView1.ColumnHeaders.Add , , "Col 2"
ListView1.ColumnHeaders.Add , , "Col 3"
ListView1.HideSelection = False
ListView1.FullRowSelect = True
ListView1.LabelEdit = lvwManual
ListView1.View = lvwReport
'Add content
ListView1.ListItems.Add , , "Col 1"
ListView1.ListItems(1).SubItems(1) = "Col 2"
ListView1.ListItems(1).SubItems(2) = "Col 3"
ListView1.ListItems.Add , , "Col 1"
ListView1.ListItems(1).SubItems(1) = "Col 2"
ListView1.ListItems(1).SubItems(2) = "Col 3"
ListView1.ListItems.Add , , "Col 1"
ListView1.ListItems(1).SubItems(1) = "Col 2"
ListView1.ListItems(1).SubItems(2) = "Col 3"
'Chenge the positioning.
ListView1.ColumnHeaders.Item(1).Position = 3 'Checkbox in column 3
ListView1.ColumnHeaders.Item(2).Position = 1
ListView1.ColumnHeaders.Item(3).Position = 2
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Thanks!
I took the code and it worked but I don't get where you set column three to have checkboxes. lets say that I want column two too also have checkboxes, what do I do?
Edit: NM, saw what you wrote in the begining of your response.