home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form LVDemoForm
- Caption = "ListView Demo"
- ClientHeight = 5145
- ClientLeft = 165
- ClientTop = 450
- ClientWidth = 9645
- LinkTopic = "Form1"
- ScaleHeight = 5145
- ScaleWidth = 9645
- StartUpPosition = 3 'Windows Default
- Begin VB.Frame Frame2
- Caption = "Icon Placement"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1350
- Left = 7785
- TabIndex = 9
- Top = 1830
- Width = 1770
- Begin VB.OptionButton AlignTop
- Caption = "Top"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 240
- Left = 165
- TabIndex = 12
- Top = 930
- Width = 1245
- End
- Begin VB.OptionButton AlignLeft
- Caption = "Left"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 240
- Left = 165
- TabIndex = 11
- Top = 637
- Width = 1245
- End
- Begin VB.OptionButton AlignNone
- Caption = "None"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 240
- Left = 165
- TabIndex = 10
- Top = 345
- Value = -1 'True
- Width = 1245
- End
- End
- Begin VB.Frame Frame1
- Caption = "List Style"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1575
- Left = 7785
- TabIndex = 4
- Top = 60
- Width = 1740
- Begin VB.OptionButton Option1
- Caption = "Icons"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 225
- Index = 0
- Left = 135
- TabIndex = 8
- Top = 330
- Width = 1545
- End
- Begin VB.OptionButton Option1
- Caption = "Small Icons"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 225
- Index = 1
- Left = 135
- TabIndex = 7
- Top = 630
- Width = 1545
- End
- Begin VB.OptionButton Option1
- Caption = "List"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 225
- Index = 2
- Left = 135
- TabIndex = 6
- Top = 915
- Width = 1545
- End
- Begin VB.OptionButton Option1
- Caption = "Report"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 225
- Index = 3
- Left = 120
- TabIndex = 5
- Top = 1215
- Value = -1 'True
- Width = 1545
- End
- End
- Begin ComctlLib.ImageList ImageList1
- Left = 7200
- Top = -45
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 32
- ImageHeight = 32
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 1
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "LVWDemo.frx":0000
- Key = ""
- EndProperty
- EndProperty
- End
- Begin VB.CommandButton Command3
- Caption = "Enumerate List"
- Enabled = 0 'False
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 7785
- TabIndex = 3
- Top = 3945
- Width = 1755
- End
- Begin VB.CommandButton Command2
- Caption = "Find Item"
- Enabled = 0 'False
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 7785
- TabIndex = 2
- Top = 4530
- Width = 1755
- End
- Begin VB.CommandButton Command1
- Caption = "Populate List"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 7785
- TabIndex = 1
- Top = 3360
- Width = 1755
- End
- Begin ComctlLib.ListView ListView1
- Height = 4920
- Left = 75
- TabIndex = 0
- Top = 120
- Width = 7605
- _ExtentX = 13414
- _ExtentY = 8678
- LabelWrap = -1 'True
- HideSelection = 0 'False
- AllowReorder = -1 'True
- FullRowSelect = -1 'True
- GridLines = -1 'True
- _Version = 393217
- Icons = "ImageList1"
- ForeColor = -2147483640
- BackColor = -2147483643
- BorderStyle = 1
- Appearance = 1
- NumItems = 1
- BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
- Object.Width = 2540
- EndProperty
- _Items = "LVWDemo.frx":0454
- End
- Attribute VB_Name = "LVDemoForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Private Sub AlignLeft_Click()
- ListView1.Arrange = lvwAutoLeft
- End Sub
- Private Sub AlignNone_Click()
- ListView1.Arrange = lvwNone
- End Sub
- Private Sub AlignTop_Click()
- ListView1.Arrange = lvwAutoTop
- End Sub
- Private Sub Command1_Click()
- ' This subroutine populates the ListView control.
- ' The data used here came from the NWIND sample database
- Dim LItem As ListItem
- Set LItem = ListView1.ListItems.Add(, , "Alfreds Futterkiste", 1)
- LItem.SubItems(1) = "Anders Maria"
- LItem.SubItems(2) = "030-0074321"
- LItem.SubItems(3) = "030-0076545"
- Set LItem = ListView1.ListItems.Add(, , "Around the Horn", 1)
- LItem.SubItems(1) = "Hardy Thomas"
- LItem.SubItems(2) = "(171) 555-7788"
- LItem.SubItems(3) = "(171) 555-6750"
- Set LItem = ListView1.ListItems.Add(, , "Bottom-Dollar Markets", 1)
- LItem.SubItems(1) = "Lincoln Elizabeth"
- LItem.SubItems(2) = "(604) 555-4729"
- LItem.SubItems(3) = "(604) 555-3745"
- Set LItem = ListView1.ListItems.Add(, , "Cactus Comidas para llevar", 1)
- LItem.SubItems(1) = "SimpsonPatricio"
- LItem.SubItems(2) = "(1)135-5555"
- LItem.SubItems(3) = "(1)135-4892"
- Set LItem = ListView1.ListItems.Add(, , "Eastern Connection", 1)
- LItem.SubItems(1) = "Devon Ann"
- LItem.SubItems(2) = "(171) 555-0297"
- LItem.SubItems(3) = "(171) 555-3373"
- Set LItem = ListView1.ListItems.Add(, , "Galer
- a del gastr
- nomo", 1)
- LItem.SubItems(1) = "Saavedra Eduardo"
- LItem.SubItems(2) = "(93) 203 4560"
- LItem.SubItems(3) = "(93) 203 4561"
- Set LItem = ListView1.ListItems.Add(, , "Godos Cocina T
- pica", 1)
- LItem.SubItems(1) = "Freyre Jos
- Pedro"
- LItem.SubItems(2) = "(95) 555 82 82"
- 'LItem.SubItems(3) = "(93) 203 4561"
- Set LItem = ListView1.ListItems.Add(, , "Island Trading", 1)
- LItem.SubItems(1) = "Bennett Helen"
- LItem.SubItems(2) = "(198) 555-8888"
- 'LItem.SubItems(3) = "(93) 203 4561"
- Set LItem = ListView1.ListItems.Add(, , "La maison d'Asie", 1)
- LItem.SubItems(1) = "Roulet Annette"
- LItem.SubItems(2) = "61.77.61.10"
- LItem.SubItems(3) = "61.77.61.11"
- Set LItem = ListView1.ListItems.Add(, , "M
- re Paillarde", 1)
- LItem.SubItems(1) = "Fresni
- re Jean"
- LItem.SubItems(2) = "(514) 555-8054"
- LItem.SubItems(3) = "(514) 555-8055"
- Set LItem = ListView1.ListItems.Add(, , "Rattlesnake Canyon Grocery", 1)
- LItem.SubItems(1) = "Wilson Paula"
- LItem.SubItems(2) = "(505) 555-5939"
- LItem.SubItems(3) = "(505) 555-3620"
- Set LItem = ListView1.ListItems.Add(, , "The Big Cheese", 1)
- LItem.SubItems(1) = "Nixon Liz"
- LItem.SubItems(2) = "(503) 555-3612"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Victuailles en stock", 1)
- LItem.SubItems(1) = "SaveleyMary"
- LItem.SubItems(2) = "78.32.54.86"
- LItem.SubItems(3) = "78.32.54.87"
- Set LItem = ListView1.ListItems.Add(, , "Die Wandernde Kuh", 1)
- LItem.SubItems(1) = "M
- ller Rita"
- LItem.SubItems(2) = "0711-020361"
- LItem.SubItems(3) = "0711-035428"
- Set LItem = ListView1.ListItems.Add(, , "Wartian Herkku", 1)
- LItem.SubItems(1) = "Koskitalo Pirkko"
- LItem.SubItems(2) = "981-443655"
- LItem.SubItems(3) = "981-443655"
- Set LItem = ListView1.ListItems.Add(, , "Wellington Importadora", 1)
- LItem.SubItems(1) = "Parente Paula"
- LItem.SubItems(2) = "(14) 555-8122"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "White Clover Markets", 1)
- LItem.SubItems(1) = "Jablonski Karl"
- LItem.SubItems(2) = "(206) 555-4112"
- LItem.SubItems(3) = "(206) 555-4115"
- Set LItem = ListView1.ListItems.Add(, , "Wilman Kala", 1)
- LItem.SubItems(1) = "Karttunen Matti"
- LItem.SubItems(2) = "90-224 8858"
- LItem.SubItems(3) = "90-224 8858"
- Set LItem = ListView1.ListItems.Add(, , "Toms Spezialit
- ten", 1)
- LItem.SubItems(1) = "Josephs Karin"
- LItem.SubItems(2) = "0251-031259"
- LItem.SubItems(3) = "0251-035695"
- Set LItem = ListView1.ListItems.Add(, , "Magazzini Alimentari Riuniti", 1)
- LItem.SubItems(1) = "Rovelli Giovanni"
- LItem.SubItems(2) = "035-640230"
- LItem.SubItems(3) = "035-640231"
- Set LItem = ListView1.ListItems.Add(, , "LILA-Supermercado", 1)
- LItem.SubItems(1) = "Gonz
- lez Carlos"
- LItem.SubItems(2) = "(9) 331-6954"
- LItem.SubItems(3) = "(9) 331-7256"
- Set LItem = ListView1.ListItems.Add(, , "Maison Dewey", 1)
- LItem.SubItems(1) = "Dewey Catherine"
- LItem.SubItems(2) = "(02) 201 24 67"
- LItem.SubItems(3) = "(02) 201 24 68"
- Set LItem = ListView1.ListItems.Add(, , "Old World Delicatessen", 1)
- LItem.SubItems(1) = "Phillips Rene"
- LItem.SubItems(2) = "(907) 555-7584"
- LItem.SubItems(3) = "(907) 555-2880"
- Set LItem = ListView1.ListItems.Add(, , "Queen Cozinha", 1)
- LItem.SubItems(1) = "Carvalho L
- LItem.SubItems(2) = "(11) 555-1189"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Simons bistro", 1)
- LItem.SubItems(1) = "Petersen Jytte"
- LItem.SubItems(2) = "31 12 34 56"
- LItem.SubItems(3) = "31 13 35 57"
- Set LItem = ListView1.ListItems.Add(, , "Frankenversand", 1)
- LItem.SubItems(1) = "Franken Peter"
- LItem.SubItems(2) = "089-0877310"
- LItem.SubItems(3) = "089-0877451"
- Set LItem = ListView1.ListItems.Add(, , "Familia Arquibaldo", 1)
- LItem.SubItems(1) = "Cruz Aria"
- LItem.SubItems(2) = "(11) 555-9857"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Gourmet Lanchonetes", 1)
- LItem.SubItems(1) = "Andr
- Fonseca"
- LItem.SubItems(2) = "(11) 555-9482"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "La corne d'abondance", 1)
- LItem.SubItems(1) = "Tonini Daniel"
- LItem.SubItems(2) = "30.59.84.10"
- LItem.SubItems(3) = "30.59.85.11"
- Set LItem = ListView1.ListItems.Add(, , "Wolski Zajazd", 1)
- LItem.SubItems(1) = "Piestrzeniewicz Zbyszek"
- LItem.SubItems(2) = "(26) 642-7012"
- LItem.SubItems(3) = "(26) 642-7012"
- Set LItem = ListView1.ListItems.Add(, , "Vaffeljernet", 1)
- LItem.SubItems(1) = "Ibsen Palle"
- LItem.SubItems(2) = "86 21 32 43"
- LItem.SubItems(3) = "86 22 33 44"
- Set LItem = ListView1.ListItems.Add(, , "Let's Stop N Shop", 1)
- LItem.SubItems(1) = "Jaime Yorres"
- LItem.SubItems(2) = "(415) 555-5938"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Oc
- ano Atl
- ntico Ltda.", 1)
- LItem.SubItems(1) = "Moncada Yvonne"
- LItem.SubItems(2) = "(1) 135-5333"
- LItem.SubItems(3) = "(1) 135-5535"
- Set LItem = ListView1.ListItems.Add(, , "LINO-Delicateses", 1)
- LItem.SubItems(1) = "Izquierdo Felipe"
- LItem.SubItems(2) = "(8) 34-56-12"
- LItem.SubItems(3) = "(8) 34-93-93"
- Set LItem = ListView1.ListItems.Add(, , "North/South", 1)
- LItem.SubItems(1) = "Crowther Simon"
- LItem.SubItems(2) = "(171) 555-7733"
- LItem.SubItems(3) = "(171) 555-2530"
- Set LItem = ListView1.ListItems.Add(, , "Reggiani Caseifici", 1)
- LItem.SubItems(1) = "Moroni Maurizio"
- LItem.SubItems(2) = "0522-556721"
- LItem.SubItems(3) = "0522-556722"
- Set LItem = ListView1.ListItems.Add(, , "Richter Supermarkt", 1)
- LItem.SubItems(1) = "Holz Michael"
- LItem.SubItems(2) = "0897-034214"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Split Rail Beer & Ale", 1)
- LItem.SubItems(1) = "Braunschweiger Art"
- LItem.SubItems(2) = "(307) 555-4680"
- LItem.SubItems(3) = "(307) 555-6525"
- Set LItem = ListView1.ListItems.Add(, , "Folk och f
- HB", 1)
- LItem.SubItems(1) = "Larsson Maria"
- LItem.SubItems(2) = "0695-34 67 21"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Chop-suey Chinese", 1)
- LItem.SubItems(1) = "Wang Yang"
- LItem.SubItems(2) = "0452-076545"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Blondel p
- re et fils", 1)
- LItem.SubItems(1) = "Citeaux Fr
- rique"
- LItem.SubItems(2) = "88.60.15.31"
- LItem.SubItems(3) = "88.60.15.32"
- Set LItem = ListView1.ListItems.Add(, , "Berglunds snabbk
- p", 1)
- LItem.SubItems(1) = "Berglund Christina"
- LItem.SubItems(2) = "0921-12 34 65"
- LItem.SubItems(3) = "0921-12 34 67"
- Set LItem = ListView1.ListItems.Add(, , "Blauer See Delikatessen", 1)
- LItem.SubItems(1) = "Moos Hanna"
- LItem.SubItems(2) = "0621-08460"
- LItem.SubItems(3) = "0621-08924"
- Set LItem = ListView1.ListItems.Add(, , "Bon app'", 1)
- LItem.SubItems(1) = "Lebihan Laurence"
- LItem.SubItems(2) = "91.24.45.40"
- LItem.SubItems(3) = "91.24.45.41"
- Set LItem = ListView1.ListItems.Add(, , "Com
- rcio Mineiro", 1)
- LItem.SubItems(1) = "Afonso Pedro"
- LItem.SubItems(2) = "(11) 555-7647"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "France restauration", 1)
- LItem.SubItems(1) = "Carine Schmitt"
- LItem.SubItems(2) = "40.32.21.21"
- LItem.SubItems(3) = "40.32.21.20"
- Set LItem = ListView1.ListItems.Add(, , "Furia Bacalhau e Frutos do Mar", 1)
- LItem.SubItems(1) = "Rodriguez Lino"
- LItem.SubItems(2) = "(1) 354-2534"
- LItem.SubItems(3) = "(1) 354-2535"
- Set LItem = ListView1.ListItems.Add(, , "Ottilies K
- seladen", 1)
- LItem.SubItems(1) = "Henriette Pfalzheim"
- LItem.SubItems(2) = "0221-0644327"
- LItem.SubItems(3) = "0221-0765721"
- Set LItem = ListView1.ListItems.Add(, , "Princesa Isabel Vinhos", 1)
- LItem.SubItems(1) = "de Castro Isabel"
- LItem.SubItems(2) = "(1) 356-5634"
- LItem.SubItems(3) = ""
- Set LItem = ListView1.ListItems.Add(, , "Romero y tomillo", 1)
- LItem.SubItems(1) = "Camino Alejandra"
- LItem.SubItems(2) = "(91) 745 6200"
- LItem.SubItems(3) = "(91) 745 6210"
- Set LItem = ListView1.ListItems.Add(, , "Trail's Head Gourmet Provisioners", 1)
- LItem.SubItems(1) = "Nagy Helvetius"
- LItem.SubItems(2) = "(206) 555-8257"
- LItem.SubItems(3) = "(206) 555-2174"
- Command2.Enabled = True
- Command3.Enabled = True
- End Sub
- Private Sub Command2_Click()
- Dim LItem As ListItem
- ' what to find
- FindItem = InputBox("Find what?")
- ' search in the list's Items
- Set LItem = ListView1.FindItem(FindItem, lvwText, , lvwPartial)
- If LItem Is Nothing Then
- ' if not found, then search for the same argument in the subitems
- Set LItem = ListView1.FindItem(FindItem, lvwSubItem)
- If LItem Is Nothing Then
- NotFound = True
- End If
- End If
- ' if the item was not found anywhere, do nothing
- If NotFound Then
- MsgBox "Item not found"
- Exit Sub
- Else
- ' else make the found item visible
- LItem.EnsureVisible
- LItem.Selected = True
- Debug.Print LItem.Text
- End If
- End Sub
- Private Sub Command3_Click()
- ' This subroutine scans the items of the ListView
- ' and prints all items and their subitems in the Immediate window
- ' in the following format:
- ' Blauer See Delikatessen
- ' Contact Moos Hanna
- ' Phone # 0621-08460
- ' FAX # 0621-08924
- Dim i As Integer, j As Integer
- Dim LItem As ListItem
- For i = 1 To ListView1.ListItems.Count
- Set LItem = ListView1.ListItems(i)
- Debug.Print LItem.Text
- For j = 1 To LItem.ListSubItems.Count
- Debug.Print Space(5) & ListView1.ColumnHeaders(j + 1).Text & " " & LItem.ListSubItems(j)
- Next
- Next
- End Sub
- Private Sub Form_Load()
- Dim LHeader As ColumnHeader
- ' when the Form is loaded, the following code sets the
- ' headers and width of the columns of the ListView control
- Set ListView1.Icons = ImageList1
- LWidth = ListView1.Width - 6 * Screen.TwipsPerPixelX
- Set LHeader = ListView1.ColumnHeaders.Add(1, , "Company", LWidth / 4)
- Set LHeader = ListView1.ColumnHeaders.Add(2, , "Contact", LWidth / 4)
- Set LHeader = ListView1.ColumnHeaders.Add(3, , "Phone #", LWidth / 4)
- Set LHeader = ListView1.ColumnHeaders.Add(4, , "FAX #", LWidth / 4)
- ListView1.View = lvwReport
- End Sub
- Private Sub ListView1_ColumnClick(ByVal ColumnHeader As ComctlLib.ColumnHeader)
- ' when a column header is clicked, the list's items are sorted
- ' according to this column's values.
- ' Only the first two columns (Company Name and Contact Name) can be used as sort keys
- If ColumnHeader.Index > 2 Then Exit Sub
- ListView1.SortKey = ColumnHeader.SubItemIndex
- ListView1.Sorted = True
- End Sub
- Private Sub ListView1_DblClick()
- ' When the user double clicks on an item, this subroutine figures out
- ' which item was double clicked.
- ' The code makes uses of an API function (the GetCursorPos() function)
- ' and the control's HitTest method to figure out where the mouse was
- ' double-clicked and which item was clicked.
- ' The code is a bit involved, but you can use it as is in your code.
- ' The LItem variable represents the item that was double-clicked and
- ' you can use it to manipulate the item.
- Dim dPoint As POINTAPI
- Dim LItem As ListItem
- If Not ListView1.View = lvwIcon Then Exit Sub
- ' Get the cursors position in screen coordinates (in pixels)
- GetCursorPos dPoint
- ' convert screen coordinates to coordinates on the ListView control (in pixels)
- X = dPoint.X - ScaleX(Me.Left + ListView1.Left, vbTwips, vbPixels)
- Y = dPoint.Y - ScaleY(Me.Top + ListView1.Top, vbTwips, vbPixels)
- On Error Resume Next
- ' Now call the HitTest method to find out the item at coordinates (X, Y)
- ' Notice that the coordinates must be converted from pixels to twips
- ' The HitTest method requires that the coordinates are expressed in twips
- Set LItem = ListView1.HitTest(ScaleX(X, vbPixels, vbTwips), ScaleY(Y, vbPixels, vbTwips))
- ' If no item was clicked, exit
- If LItem Is Nothing Then Exit Sub
- ' If an item was clicked, then display its subitems in a message box
- ' Notice that the code reacts only if the items are displayed as Icons or Small Icons
- If ListView1.View = lvwIcon Or ListView1.View = lvwSmallIcon Then
- LItem.Selected = True
- msg = LItem.Text & vbCrLf
- For i = 1 To LItem.ListSubItems.Count
- msg = msg & " " & LItem.ListSubItems(i).Text & vbCrLf
- Next
- MsgBox msg
- End If
- End Sub
- Private Sub ListView1_ItemClick(ByVal Item As ComctlLib.ListItem)
- ' This subroutine displays the subitems of the item that was clicked
- ' The code reacts only if the items are displayed in List mode
- If ListView1.View = lvwList Then
- msg = ListView1.SelectedItem.Text & vbCrLf
- For i = 1 To ListView1.SelectedItem.ListSubItems.Count
- msg = msg & " " & ListView1.SelectedItem.ListSubItems(i).Text & vbCrLf
- Next
- MsgBox msg
- End If
- End Sub
- Private Sub Option1_Click(Index As Integer)
- ListView1.View = Index
- End Sub
-