lionne
04-07-2013, 10:30 AM
Dear all
I've got one issue, which I unfortunately couldn't solve on my own. How one could insert a CheckBox into a SubItem of a ListView?
Here's the screenshot of my UserForm. I'd like to have my first column being the last one.
http://i47.tinypic.com/k4x99g.png
Here is my code:
Private Sub UserForm_Activate()
Dim wb As Workbook
Dim pc As Worksheet
Dim Row, tc_num As Integer
Set wb = Excel.ActiveWorkbook
Set pc = wb.Sheets("PhysCase")
Dim li As ListItem
'count how many test cases are there
Row = 2
While Not IsEmpty(pc.Cells(Row, 1))
Row = Row + 1
Wend
tc_num = Row - 1
'populate the list view
With Me.lsv_tcList
.CheckBoxes = True
.ColumnHeaders.Add , , "STP"
.ColumnHeaders(1).Width = 25
.ColumnHeaders.Add , , "ID"
.ColumnHeaders(2).Width = 25
.ColumnHeaders.Add , , "TC Name"
.ColumnHeaders(3).Width = 360
.HideColumnHeaders = False
.View = 3
.Gridlines = True
.MultiSelect = True
For Row = 2 To tc_num
Set li = .ListItems.Add(, , "")
li.SubItems(1) = pc.Cells(Row, 1).Value
li.SubItems(2) = pc.Cells(Row, 2).Value
Next
End With
End Sub
Did anyone experience the same problem?
Also, when I select the row in a ListBox control, the whole row is selected. Here only the first column. Is there a way to have the same selection behaviour is ListView as in ListBox?
Any hints will be highly appreciated,
Regards
Lionne
http://postimg.org/image/b3ln3orsv/
I've got one issue, which I unfortunately couldn't solve on my own. How one could insert a CheckBox into a SubItem of a ListView?
Here's the screenshot of my UserForm. I'd like to have my first column being the last one.
http://i47.tinypic.com/k4x99g.png
Here is my code:
Private Sub UserForm_Activate()
Dim wb As Workbook
Dim pc As Worksheet
Dim Row, tc_num As Integer
Set wb = Excel.ActiveWorkbook
Set pc = wb.Sheets("PhysCase")
Dim li As ListItem
'count how many test cases are there
Row = 2
While Not IsEmpty(pc.Cells(Row, 1))
Row = Row + 1
Wend
tc_num = Row - 1
'populate the list view
With Me.lsv_tcList
.CheckBoxes = True
.ColumnHeaders.Add , , "STP"
.ColumnHeaders(1).Width = 25
.ColumnHeaders.Add , , "ID"
.ColumnHeaders(2).Width = 25
.ColumnHeaders.Add , , "TC Name"
.ColumnHeaders(3).Width = 360
.HideColumnHeaders = False
.View = 3
.Gridlines = True
.MultiSelect = True
For Row = 2 To tc_num
Set li = .ListItems.Add(, , "")
li.SubItems(1) = pc.Cells(Row, 1).Value
li.SubItems(2) = pc.Cells(Row, 2).Value
Next
End With
End Sub
Did anyone experience the same problem?
Also, when I select the row in a ListBox control, the whole row is selected. Here only the first column. Is there a way to have the same selection behaviour is ListView as in ListBox?
Any hints will be highly appreciated,
Regards
Lionne
http://postimg.org/image/b3ln3orsv/