|
楼主 |
发表于 2016-10-10 17:00
|
显示全部楼层
赵老师还是麻烦你指导帮修改一下
Private Sub TreeView1_Click()
Dim Itm As ListItem
'arr = Sheet1.Range("a1").CurrentRegion
jcm = TreeView1.SelectedItem.Key
jc = Right(jcm, 1) '根据级次来判断应找哪一列
jcm = Left(jcm, Len(jcm) - 1)
ListView1.ListItems.Clear
'For i = 2 To UBound(arr)
'If jc <> "0" Then
'If arr(i, jc) = jcm Then
'Set Itm = ListView1.ListItems.Add()
'Itm.Text = Sheet1.Cells(i, 1)
'Itm.SubItems(1) = Sheet1.Cells(i, 2)
'Itm.SubItems(2) = Sheet1.Cells(i, 3)
'Itm.SubItems(3) = Sheet1.Cells(i, 4)
'End If
'Else
'Set Itm = ListView1.ListItems.Add()
'Itm.Text = Sheet1.Cells(i, 1)
'Itm.SubItems(1) = Sheet1.Cells(i, 2)
'Itm.SubItems(2) = Sheet1.Cells(i, 3)
'Itm.SubItems(3) = Sheet1.Cells(i, 4)
'End If
'Next
For i = 1 To rs.RecordCount
If jc <> "0" Then
'If arr(i, jc) = jcm Then
If rs.Fields(jc - 1).Value = jcm Then
Set Itm = ListView1.ListItems.Add()
Itm.Text = rs.Fields(0).Value
Itm.SubItems(1) = rs.Fields(1).Value
Itm.SubItems(2) = rs.Fields(2).Value
Itm.SubItems(3) = rs.Fields(3).Value
End If
Else
Set Itm = ListView1.ListItems.Add()
Itm.Text = rs.Fields(0).Value
Itm.SubItems(1) = rs.Fields(1).Value
Itm.SubItems(2) = rs.Fields(2).Value
Itm.SubItems(3) = rs.Fields(3).Value
End If
rs.MoveNext
Next
rs.MoveFirst
End Sub
|
|