List View question

  • Thread starter Thread starter whistler
  • Start date Start date
W

whistler

Short and crisp question:

How do you reference to listitems in multi selections in List Views?

any hints are most appreciated...

regards, Jos


--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
 
If you want the items selected, call something like this on each lstbox
click event:

Public Sub Add()
Dim frm As Form, ctl As listbox
Dim varItm As Variant
Set frm = Forms!YourformName
Set ctl = frm!YourlstboxName
' loops thru lstbox to get total selected
For Each varItm In ctl.ItemsSelected
C = C + CSng(ctl.Column(1, varItm)) 'this example just adds the
numbers in columns 1
W = W + CSng(ctl.Column(2, varItm)) 'same as above for column 2
Next varItm
Set ctl = Nothing
Set frm = Nothing
'puts values in textboxes
Me.txtC = C
Me!txtInUse = W
End Sub

Damon
 
Hi,

Something like....

Dim ctl As MSComctlLib.ListItem
For Each ctl In Me.ctlListView.ListItems
If ctl.Selected Then
MsgBox "Row is Selected " & ctl.Value
End If
Next ctl
End Sub
 
Back
Top