Private Sub lvUser_ItemClick(ByVal Item As MSComctlLib.ListItem) On Error GoTo Errhandle If Item Is Nothing Then Exit Sub txtUID.Text = Item.Text txtTrueName.Text = Item.ListSubItems(2).Text Exit Sub Errhandle: MsgBox Err.Description End Sub
private sub listview1_click() ListView1.SelectedItem.Text '取第一项 ListView1.SelectedItem.SubItems(1) '取第二项 listview1.selecteditem.subitems(n) 'n>0 取第n项 end sub
谢谢各位的回复,已经解决问题。 Private Sub listview1_ItemClick(ByVal Item As MSComctlLib.ListItem) On Error GoTo Errhandle If Item Is Nothing Then Exit Sub ListView1.SelectedItem.Text '取第一项 ListView1.SelectedItem.SubItems(1) '取第二项 listview1.selecteditem.subitems(n) 'n >0 取第n项 Exit Sub Errhandle: MsgBox Err.Description End Sub
ListView1.SelectedItem.SubItems(1) '取第二项
listview1.selecteditem.subitems(n) 'n>0 取第n项
listview1_ColumnClick()
msgbox(ListView1.SelectedItem.Text)只有点击最顶上上那一行时才返回值啊。怎么触发这个事件呢?
On Error GoTo Errhandle
If Item Is Nothing Then Exit Sub txtUID.Text = Item.Text
txtTrueName.Text = Item.ListSubItems(2).Text Exit Sub
Errhandle:
MsgBox Err.Description
End Sub
ListView1.SelectedItem.Text '取第一项
ListView1.SelectedItem.SubItems(1) '取第二项
listview1.selecteditem.subitems(n) 'n>0 取第n项
end sub
在向LV添加数据时,在参数KEY中,使用连续的数字,这样在数据添加后,在点击LV时取出KEY的数值,然后用RECORD的MOVE方法将数据库指针移到当前记录的位置,即可显示当前的记录值方法有些笨,先用着
Private Sub listview1_ItemClick(ByVal Item As MSComctlLib.ListItem)
On Error GoTo Errhandle
If Item Is Nothing Then Exit Sub
ListView1.SelectedItem.Text '取第一项
ListView1.SelectedItem.SubItems(1) '取第二项
listview1.selecteditem.subitems(n) 'n >0 取第n项
Exit Sub
Errhandle:
MsgBox Err.Description
End Sub