home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch08 / lvwdemo / lvwdemo.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-27  |  23.9 KB  |  629 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form LVDemoForm 
  4.    Caption         =   "ListView Demo"
  5.    ClientHeight    =   5145
  6.    ClientLeft      =   165
  7.    ClientTop       =   450
  8.    ClientWidth     =   9645
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   5145
  11.    ScaleWidth      =   9645
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.Frame Frame2 
  14.       Caption         =   "Icon Placement"
  15.       BeginProperty Font 
  16.          Name            =   "Verdana"
  17.          Size            =   9
  18.          Charset         =   0
  19.          Weight          =   400
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   1350
  25.       Left            =   7785
  26.       TabIndex        =   9
  27.       Top             =   1830
  28.       Width           =   1770
  29.       Begin VB.OptionButton AlignTop 
  30.          Caption         =   "Top"
  31.          BeginProperty Font 
  32.             Name            =   "Verdana"
  33.             Size            =   9
  34.             Charset         =   0
  35.             Weight          =   400
  36.             Underline       =   0   'False
  37.             Italic          =   0   'False
  38.             Strikethrough   =   0   'False
  39.          EndProperty
  40.          Height          =   240
  41.          Left            =   165
  42.          TabIndex        =   12
  43.          Top             =   930
  44.          Width           =   1245
  45.       End
  46.       Begin VB.OptionButton AlignLeft 
  47.          Caption         =   "Left"
  48.          BeginProperty Font 
  49.             Name            =   "Verdana"
  50.             Size            =   9
  51.             Charset         =   0
  52.             Weight          =   400
  53.             Underline       =   0   'False
  54.             Italic          =   0   'False
  55.             Strikethrough   =   0   'False
  56.          EndProperty
  57.          Height          =   240
  58.          Left            =   165
  59.          TabIndex        =   11
  60.          Top             =   637
  61.          Width           =   1245
  62.       End
  63.       Begin VB.OptionButton AlignNone 
  64.          Caption         =   "None"
  65.          BeginProperty Font 
  66.             Name            =   "Verdana"
  67.             Size            =   9
  68.             Charset         =   0
  69.             Weight          =   400
  70.             Underline       =   0   'False
  71.             Italic          =   0   'False
  72.             Strikethrough   =   0   'False
  73.          EndProperty
  74.          Height          =   240
  75.          Left            =   165
  76.          TabIndex        =   10
  77.          Top             =   345
  78.          Value           =   -1  'True
  79.          Width           =   1245
  80.       End
  81.    End
  82.    Begin VB.Frame Frame1 
  83.       Caption         =   "List Style"
  84.       BeginProperty Font 
  85.          Name            =   "Verdana"
  86.          Size            =   9
  87.          Charset         =   0
  88.          Weight          =   400
  89.          Underline       =   0   'False
  90.          Italic          =   0   'False
  91.          Strikethrough   =   0   'False
  92.       EndProperty
  93.       Height          =   1575
  94.       Left            =   7785
  95.       TabIndex        =   4
  96.       Top             =   60
  97.       Width           =   1740
  98.       Begin VB.OptionButton Option1 
  99.          Caption         =   "Icons"
  100.          BeginProperty Font 
  101.             Name            =   "Verdana"
  102.             Size            =   9
  103.             Charset         =   0
  104.             Weight          =   400
  105.             Underline       =   0   'False
  106.             Italic          =   0   'False
  107.             Strikethrough   =   0   'False
  108.          EndProperty
  109.          Height          =   225
  110.          Index           =   0
  111.          Left            =   135
  112.          TabIndex        =   8
  113.          Top             =   330
  114.          Width           =   1545
  115.       End
  116.       Begin VB.OptionButton Option1 
  117.          Caption         =   "Small Icons"
  118.          BeginProperty Font 
  119.             Name            =   "Verdana"
  120.             Size            =   9
  121.             Charset         =   0
  122.             Weight          =   400
  123.             Underline       =   0   'False
  124.             Italic          =   0   'False
  125.             Strikethrough   =   0   'False
  126.          EndProperty
  127.          Height          =   225
  128.          Index           =   1
  129.          Left            =   135
  130.          TabIndex        =   7
  131.          Top             =   630
  132.          Width           =   1545
  133.       End
  134.       Begin VB.OptionButton Option1 
  135.          Caption         =   "List"
  136.          BeginProperty Font 
  137.             Name            =   "Verdana"
  138.             Size            =   9
  139.             Charset         =   0
  140.             Weight          =   400
  141.             Underline       =   0   'False
  142.             Italic          =   0   'False
  143.             Strikethrough   =   0   'False
  144.          EndProperty
  145.          Height          =   225
  146.          Index           =   2
  147.          Left            =   135
  148.          TabIndex        =   6
  149.          Top             =   915
  150.          Width           =   1545
  151.       End
  152.       Begin VB.OptionButton Option1 
  153.          Caption         =   "Report"
  154.          BeginProperty Font 
  155.             Name            =   "Verdana"
  156.             Size            =   9
  157.             Charset         =   0
  158.             Weight          =   400
  159.             Underline       =   0   'False
  160.             Italic          =   0   'False
  161.             Strikethrough   =   0   'False
  162.          EndProperty
  163.          Height          =   225
  164.          Index           =   3
  165.          Left            =   120
  166.          TabIndex        =   5
  167.          Top             =   1215
  168.          Value           =   -1  'True
  169.          Width           =   1545
  170.       End
  171.    End
  172.    Begin ComctlLib.ImageList ImageList1 
  173.       Left            =   7200
  174.       Top             =   -45
  175.       _ExtentX        =   1005
  176.       _ExtentY        =   1005
  177.       BackColor       =   -2147483643
  178.       ImageWidth      =   32
  179.       ImageHeight     =   32
  180.       MaskColor       =   12632256
  181.       _Version        =   393216
  182.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  183.          NumListImages   =   1
  184.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  185.             Picture         =   "LVWDemo.frx":0000
  186.             Key             =   ""
  187.          EndProperty
  188.       EndProperty
  189.    End
  190.    Begin VB.CommandButton Command3 
  191.       Caption         =   "Enumerate List"
  192.       Enabled         =   0   'False
  193.       BeginProperty Font 
  194.          Name            =   "Verdana"
  195.          Size            =   9
  196.          Charset         =   0
  197.          Weight          =   400
  198.          Underline       =   0   'False
  199.          Italic          =   0   'False
  200.          Strikethrough   =   0   'False
  201.       EndProperty
  202.       Height          =   495
  203.       Left            =   7785
  204.       TabIndex        =   3
  205.       Top             =   3945
  206.       Width           =   1755
  207.    End
  208.    Begin VB.CommandButton Command2 
  209.       Caption         =   "Find Item"
  210.       Enabled         =   0   'False
  211.       BeginProperty Font 
  212.          Name            =   "Verdana"
  213.          Size            =   9
  214.          Charset         =   0
  215.          Weight          =   400
  216.          Underline       =   0   'False
  217.          Italic          =   0   'False
  218.          Strikethrough   =   0   'False
  219.       EndProperty
  220.       Height          =   495
  221.       Left            =   7785
  222.       TabIndex        =   2
  223.       Top             =   4530
  224.       Width           =   1755
  225.    End
  226.    Begin VB.CommandButton Command1 
  227.       Caption         =   "Populate List"
  228.       BeginProperty Font 
  229.          Name            =   "Verdana"
  230.          Size            =   9
  231.          Charset         =   0
  232.          Weight          =   400
  233.          Underline       =   0   'False
  234.          Italic          =   0   'False
  235.          Strikethrough   =   0   'False
  236.       EndProperty
  237.       Height          =   495
  238.       Left            =   7785
  239.       TabIndex        =   1
  240.       Top             =   3360
  241.       Width           =   1755
  242.    End
  243.    Begin ComctlLib.ListView ListView1 
  244.       Height          =   4920
  245.       Left            =   75
  246.       TabIndex        =   0
  247.       Top             =   120
  248.       Width           =   7605
  249.       _ExtentX        =   13414
  250.       _ExtentY        =   8678
  251.       LabelWrap       =   -1  'True
  252.       HideSelection   =   0   'False
  253.       AllowReorder    =   -1  'True
  254.       FullRowSelect   =   -1  'True
  255.       GridLines       =   -1  'True
  256.       _Version        =   393217
  257.       Icons           =   "ImageList1"
  258.       ForeColor       =   -2147483640
  259.       BackColor       =   -2147483643
  260.       BorderStyle     =   1
  261.       Appearance      =   1
  262.       NumItems        =   1
  263.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  264.          Object.Width           =   2540
  265.       EndProperty
  266.       _Items          =   "LVWDemo.frx":0454
  267.    End
  268. Attribute VB_Name = "LVDemoForm"
  269. Attribute VB_GlobalNameSpace = False
  270. Attribute VB_Creatable = False
  271. Attribute VB_PredeclaredId = True
  272. Attribute VB_Exposed = False
  273. '  ******************************
  274. '  ******************************
  275. '  ** MASTERING VB6            **
  276. '  ** by Evangelos Petroutos   **
  277. '  ** SYBEX, 1998              **
  278. '  ******************************
  279. '  ******************************
  280. Private Sub AlignLeft_Click()
  281.     ListView1.Arrange = lvwAutoLeft
  282. End Sub
  283. Private Sub AlignNone_Click()
  284.     ListView1.Arrange = lvwNone
  285. End Sub
  286. Private Sub AlignTop_Click()
  287.     ListView1.Arrange = lvwAutoTop
  288. End Sub
  289. Private Sub Command1_Click()
  290. ' This subroutine populates the ListView control.
  291. ' The data used here came from the NWIND sample database
  292. Dim LItem As ListItem
  293. Set LItem = ListView1.ListItems.Add(, , "Alfreds Futterkiste", 1)
  294.     LItem.SubItems(1) = "Anders Maria"
  295.     LItem.SubItems(2) = "030-0074321"
  296.     LItem.SubItems(3) = "030-0076545"
  297. Set LItem = ListView1.ListItems.Add(, , "Around the Horn", 1)
  298.     LItem.SubItems(1) = "Hardy Thomas"
  299.     LItem.SubItems(2) = "(171) 555-7788"
  300.     LItem.SubItems(3) = "(171) 555-6750"
  301. Set LItem = ListView1.ListItems.Add(, , "Bottom-Dollar Markets", 1)
  302.     LItem.SubItems(1) = "Lincoln Elizabeth"
  303.     LItem.SubItems(2) = "(604) 555-4729"
  304.     LItem.SubItems(3) = "(604) 555-3745"
  305. Set LItem = ListView1.ListItems.Add(, , "Cactus Comidas para llevar", 1)
  306.     LItem.SubItems(1) = "SimpsonPatricio"
  307.     LItem.SubItems(2) = "(1)135-5555"
  308.     LItem.SubItems(3) = "(1)135-4892"
  309. Set LItem = ListView1.ListItems.Add(, , "Eastern Connection", 1)
  310.     LItem.SubItems(1) = "Devon Ann"
  311.     LItem.SubItems(2) = "(171) 555-0297"
  312.     LItem.SubItems(3) = "(171) 555-3373"
  313. Set LItem = ListView1.ListItems.Add(, , "Galer
  314. a del gastr
  315. nomo", 1)
  316.     LItem.SubItems(1) = "Saavedra Eduardo"
  317.     LItem.SubItems(2) = "(93) 203 4560"
  318.     LItem.SubItems(3) = "(93) 203 4561"
  319. Set LItem = ListView1.ListItems.Add(, , "Godos Cocina T
  320. pica", 1)
  321.     LItem.SubItems(1) = "Freyre Jos
  322.  Pedro"
  323.     LItem.SubItems(2) = "(95) 555 82 82"
  324.     'LItem.SubItems(3) = "(93) 203 4561"
  325. Set LItem = ListView1.ListItems.Add(, , "Island Trading", 1)
  326.     LItem.SubItems(1) = "Bennett Helen"
  327.     LItem.SubItems(2) = "(198) 555-8888"
  328.     'LItem.SubItems(3) = "(93) 203 4561"
  329. Set LItem = ListView1.ListItems.Add(, , "La maison d'Asie", 1)
  330.     LItem.SubItems(1) = "Roulet Annette"
  331.     LItem.SubItems(2) = "61.77.61.10"
  332.     LItem.SubItems(3) = "61.77.61.11"
  333. Set LItem = ListView1.ListItems.Add(, , "M
  334. re Paillarde", 1)
  335.     LItem.SubItems(1) = "Fresni
  336. re Jean"
  337.     LItem.SubItems(2) = "(514) 555-8054"
  338.     LItem.SubItems(3) = "(514) 555-8055"
  339. Set LItem = ListView1.ListItems.Add(, , "Rattlesnake Canyon Grocery", 1)
  340.     LItem.SubItems(1) = "Wilson Paula"
  341.     LItem.SubItems(2) = "(505) 555-5939"
  342.     LItem.SubItems(3) = "(505) 555-3620"
  343. Set LItem = ListView1.ListItems.Add(, , "The Big Cheese", 1)
  344.     LItem.SubItems(1) = "Nixon Liz"
  345.     LItem.SubItems(2) = "(503) 555-3612"
  346.     LItem.SubItems(3) = ""
  347. Set LItem = ListView1.ListItems.Add(, , "Victuailles en stock", 1)
  348.     LItem.SubItems(1) = "SaveleyMary"
  349.     LItem.SubItems(2) = "78.32.54.86"
  350.     LItem.SubItems(3) = "78.32.54.87"
  351. Set LItem = ListView1.ListItems.Add(, , "Die Wandernde Kuh", 1)
  352.     LItem.SubItems(1) = "M
  353. ller Rita"
  354.     LItem.SubItems(2) = "0711-020361"
  355.     LItem.SubItems(3) = "0711-035428"
  356. Set LItem = ListView1.ListItems.Add(, , "Wartian Herkku", 1)
  357.     LItem.SubItems(1) = "Koskitalo Pirkko"
  358.     LItem.SubItems(2) = "981-443655"
  359.     LItem.SubItems(3) = "981-443655"
  360. Set LItem = ListView1.ListItems.Add(, , "Wellington Importadora", 1)
  361.     LItem.SubItems(1) = "Parente Paula"
  362.     LItem.SubItems(2) = "(14) 555-8122"
  363.     LItem.SubItems(3) = ""
  364. Set LItem = ListView1.ListItems.Add(, , "White Clover Markets", 1)
  365.     LItem.SubItems(1) = "Jablonski Karl"
  366.     LItem.SubItems(2) = "(206) 555-4112"
  367.     LItem.SubItems(3) = "(206) 555-4115"
  368. Set LItem = ListView1.ListItems.Add(, , "Wilman Kala", 1)
  369.     LItem.SubItems(1) = "Karttunen Matti"
  370.     LItem.SubItems(2) = "90-224 8858"
  371.     LItem.SubItems(3) = "90-224 8858"
  372. Set LItem = ListView1.ListItems.Add(, , "Toms Spezialit
  373. ten", 1)
  374.     LItem.SubItems(1) = "Josephs Karin"
  375.     LItem.SubItems(2) = "0251-031259"
  376.     LItem.SubItems(3) = "0251-035695"
  377. Set LItem = ListView1.ListItems.Add(, , "Magazzini Alimentari Riuniti", 1)
  378.     LItem.SubItems(1) = "Rovelli Giovanni"
  379.     LItem.SubItems(2) = "035-640230"
  380.     LItem.SubItems(3) = "035-640231"
  381. Set LItem = ListView1.ListItems.Add(, , "LILA-Supermercado", 1)
  382.     LItem.SubItems(1) = "Gonz
  383. lez Carlos"
  384.     LItem.SubItems(2) = "(9) 331-6954"
  385.     LItem.SubItems(3) = "(9) 331-7256"
  386. Set LItem = ListView1.ListItems.Add(, , "Maison Dewey", 1)
  387.     LItem.SubItems(1) = "Dewey Catherine"
  388.     LItem.SubItems(2) = "(02) 201 24 67"
  389.     LItem.SubItems(3) = "(02) 201 24 68"
  390. Set LItem = ListView1.ListItems.Add(, , "Old World Delicatessen", 1)
  391.     LItem.SubItems(1) = "Phillips Rene"
  392.     LItem.SubItems(2) = "(907) 555-7584"
  393.     LItem.SubItems(3) = "(907) 555-2880"
  394. Set LItem = ListView1.ListItems.Add(, , "Queen Cozinha", 1)
  395.     LItem.SubItems(1) = "Carvalho L
  396.     LItem.SubItems(2) = "(11) 555-1189"
  397.     LItem.SubItems(3) = ""
  398. Set LItem = ListView1.ListItems.Add(, , "Simons bistro", 1)
  399.     LItem.SubItems(1) = "Petersen Jytte"
  400.     LItem.SubItems(2) = "31 12 34 56"
  401.     LItem.SubItems(3) = "31 13 35 57"
  402. Set LItem = ListView1.ListItems.Add(, , "Frankenversand", 1)
  403.     LItem.SubItems(1) = "Franken Peter"
  404.     LItem.SubItems(2) = "089-0877310"
  405.     LItem.SubItems(3) = "089-0877451"
  406. Set LItem = ListView1.ListItems.Add(, , "Familia Arquibaldo", 1)
  407.     LItem.SubItems(1) = "Cruz Aria"
  408.     LItem.SubItems(2) = "(11) 555-9857"
  409.     LItem.SubItems(3) = ""
  410. Set LItem = ListView1.ListItems.Add(, , "Gourmet Lanchonetes", 1)
  411.     LItem.SubItems(1) = "Andr
  412.  Fonseca"
  413.     LItem.SubItems(2) = "(11) 555-9482"
  414.     LItem.SubItems(3) = ""
  415. Set LItem = ListView1.ListItems.Add(, , "La corne d'abondance", 1)
  416.     LItem.SubItems(1) = "Tonini Daniel"
  417.     LItem.SubItems(2) = "30.59.84.10"
  418.     LItem.SubItems(3) = "30.59.85.11"
  419. Set LItem = ListView1.ListItems.Add(, , "Wolski  Zajazd", 1)
  420.     LItem.SubItems(1) = "Piestrzeniewicz Zbyszek"
  421.     LItem.SubItems(2) = "(26) 642-7012"
  422.     LItem.SubItems(3) = "(26) 642-7012"
  423. Set LItem = ListView1.ListItems.Add(, , "Vaffeljernet", 1)
  424.     LItem.SubItems(1) = "Ibsen Palle"
  425.     LItem.SubItems(2) = "86 21 32 43"
  426.     LItem.SubItems(3) = "86 22 33 44"
  427. Set LItem = ListView1.ListItems.Add(, , "Let's Stop N Shop", 1)
  428.     LItem.SubItems(1) = "Jaime Yorres"
  429.     LItem.SubItems(2) = "(415) 555-5938"
  430.     LItem.SubItems(3) = ""
  431. Set LItem = ListView1.ListItems.Add(, , "Oc
  432. ano Atl
  433. ntico Ltda.", 1)
  434.     LItem.SubItems(1) = "Moncada Yvonne"
  435.     LItem.SubItems(2) = "(1) 135-5333"
  436.     LItem.SubItems(3) = "(1) 135-5535"
  437. Set LItem = ListView1.ListItems.Add(, , "LINO-Delicateses", 1)
  438.     LItem.SubItems(1) = "Izquierdo Felipe"
  439.     LItem.SubItems(2) = "(8) 34-56-12"
  440.     LItem.SubItems(3) = "(8) 34-93-93"
  441. Set LItem = ListView1.ListItems.Add(, , "North/South", 1)
  442.     LItem.SubItems(1) = "Crowther Simon"
  443.     LItem.SubItems(2) = "(171) 555-7733"
  444.     LItem.SubItems(3) = "(171) 555-2530"
  445. Set LItem = ListView1.ListItems.Add(, , "Reggiani Caseifici", 1)
  446.     LItem.SubItems(1) = "Moroni Maurizio"
  447.     LItem.SubItems(2) = "0522-556721"
  448.     LItem.SubItems(3) = "0522-556722"
  449. Set LItem = ListView1.ListItems.Add(, , "Richter Supermarkt", 1)
  450.     LItem.SubItems(1) = "Holz Michael"
  451.     LItem.SubItems(2) = "0897-034214"
  452.     LItem.SubItems(3) = ""
  453. Set LItem = ListView1.ListItems.Add(, , "Split Rail Beer & Ale", 1)
  454.     LItem.SubItems(1) = "Braunschweiger Art"
  455.     LItem.SubItems(2) = "(307) 555-4680"
  456.     LItem.SubItems(3) = "(307) 555-6525"
  457. Set LItem = ListView1.ListItems.Add(, , "Folk och f
  458.  HB", 1)
  459.     LItem.SubItems(1) = "Larsson Maria"
  460.     LItem.SubItems(2) = "0695-34 67 21"
  461.     LItem.SubItems(3) = ""
  462. Set LItem = ListView1.ListItems.Add(, , "Chop-suey Chinese", 1)
  463.     LItem.SubItems(1) = "Wang Yang"
  464.     LItem.SubItems(2) = "0452-076545"
  465.     LItem.SubItems(3) = ""
  466. Set LItem = ListView1.ListItems.Add(, , "Blondel p
  467. re et fils", 1)
  468.     LItem.SubItems(1) = "Citeaux Fr
  469. rique"
  470.     LItem.SubItems(2) = "88.60.15.31"
  471.     LItem.SubItems(3) = "88.60.15.32"
  472. Set LItem = ListView1.ListItems.Add(, , "Berglunds snabbk
  473. p", 1)
  474.     LItem.SubItems(1) = "Berglund Christina"
  475.     LItem.SubItems(2) = "0921-12 34 65"
  476.     LItem.SubItems(3) = "0921-12 34 67"
  477. Set LItem = ListView1.ListItems.Add(, , "Blauer See Delikatessen", 1)
  478.     LItem.SubItems(1) = "Moos Hanna"
  479.     LItem.SubItems(2) = "0621-08460"
  480.     LItem.SubItems(3) = "0621-08924"
  481. Set LItem = ListView1.ListItems.Add(, , "Bon app'", 1)
  482.     LItem.SubItems(1) = "Lebihan Laurence"
  483.     LItem.SubItems(2) = "91.24.45.40"
  484.     LItem.SubItems(3) = "91.24.45.41"
  485. Set LItem = ListView1.ListItems.Add(, , "Com
  486. rcio Mineiro", 1)
  487.     LItem.SubItems(1) = "Afonso Pedro"
  488.     LItem.SubItems(2) = "(11) 555-7647"
  489.     LItem.SubItems(3) = ""
  490. Set LItem = ListView1.ListItems.Add(, , "France restauration", 1)
  491.     LItem.SubItems(1) = "Carine Schmitt"
  492.     LItem.SubItems(2) = "40.32.21.21"
  493.     LItem.SubItems(3) = "40.32.21.20"
  494. Set LItem = ListView1.ListItems.Add(, , "Furia Bacalhau e Frutos do Mar", 1)
  495.     LItem.SubItems(1) = "Rodriguez Lino"
  496.     LItem.SubItems(2) = "(1) 354-2534"
  497.     LItem.SubItems(3) = "(1) 354-2535"
  498. Set LItem = ListView1.ListItems.Add(, , "Ottilies K
  499. seladen", 1)
  500.     LItem.SubItems(1) = "Henriette Pfalzheim"
  501.     LItem.SubItems(2) = "0221-0644327"
  502.     LItem.SubItems(3) = "0221-0765721"
  503. Set LItem = ListView1.ListItems.Add(, , "Princesa Isabel Vinhos", 1)
  504.     LItem.SubItems(1) = "de Castro Isabel"
  505.     LItem.SubItems(2) = "(1) 356-5634"
  506.     LItem.SubItems(3) = ""
  507. Set LItem = ListView1.ListItems.Add(, , "Romero y tomillo", 1)
  508.     LItem.SubItems(1) = "Camino Alejandra"
  509.     LItem.SubItems(2) = "(91) 745 6200"
  510.     LItem.SubItems(3) = "(91) 745 6210"
  511. Set LItem = ListView1.ListItems.Add(, , "Trail's Head Gourmet Provisioners", 1)
  512.     LItem.SubItems(1) = "Nagy Helvetius"
  513.     LItem.SubItems(2) = "(206) 555-8257"
  514.     LItem.SubItems(3) = "(206) 555-2174"
  515.     Command2.Enabled = True
  516.     Command3.Enabled = True
  517. End Sub
  518. Private Sub Command2_Click()
  519. Dim LItem As ListItem
  520. ' what to find
  521.     FindItem = InputBox("Find what?")
  522. ' search in the list's Items
  523.     Set LItem = ListView1.FindItem(FindItem, lvwText, , lvwPartial)
  524.     If LItem Is Nothing Then
  525. ' if not found, then search for the same argument in the subitems
  526.         Set LItem = ListView1.FindItem(FindItem, lvwSubItem)
  527.         If LItem Is Nothing Then
  528.             NotFound = True
  529.         End If
  530.     End If
  531. ' if the item was not found anywhere, do nothing
  532.     If NotFound Then
  533.         MsgBox "Item not found"
  534.         Exit Sub
  535.     Else
  536. ' else make the found item visible
  537.         LItem.EnsureVisible
  538.         LItem.Selected = True
  539.         Debug.Print LItem.Text
  540.     End If
  541. End Sub
  542. Private Sub Command3_Click()
  543. ' This subroutine scans the items of the ListView
  544. ' and prints all items and their subitems in the Immediate window
  545. ' in the following format:
  546. ' Blauer See Delikatessen
  547. '     Contact    Moos Hanna
  548. '     Phone #    0621-08460
  549. '     FAX #    0621-08924
  550. Dim i As Integer, j As Integer
  551. Dim LItem As ListItem
  552.     For i = 1 To ListView1.ListItems.Count
  553.         Set LItem = ListView1.ListItems(i)
  554.         Debug.Print LItem.Text
  555.         For j = 1 To LItem.ListSubItems.Count
  556.             Debug.Print Space(5) & ListView1.ColumnHeaders(j + 1).Text & "    " & LItem.ListSubItems(j)
  557.         Next
  558.     Next
  559. End Sub
  560. Private Sub Form_Load()
  561. Dim LHeader As ColumnHeader
  562. ' when the Form is loaded, the following code sets the
  563. ' headers and width of the columns of the ListView control
  564.     Set ListView1.Icons = ImageList1
  565.     LWidth = ListView1.Width - 6 * Screen.TwipsPerPixelX
  566.     Set LHeader = ListView1.ColumnHeaders.Add(1, , "Company", LWidth / 4)
  567.     Set LHeader = ListView1.ColumnHeaders.Add(2, , "Contact", LWidth / 4)
  568.     Set LHeader = ListView1.ColumnHeaders.Add(3, , "Phone #", LWidth / 4)
  569.     Set LHeader = ListView1.ColumnHeaders.Add(4, , "FAX #", LWidth / 4)
  570.     ListView1.View = lvwReport
  571. End Sub
  572. Private Sub ListView1_ColumnClick(ByVal ColumnHeader As ComctlLib.ColumnHeader)
  573. ' when a column header is clicked, the list's items are sorted
  574. ' according to this column's values.
  575. ' Only the first two columns (Company Name and Contact Name) can be used as sort keys
  576.     If ColumnHeader.Index > 2 Then Exit Sub
  577.     ListView1.SortKey = ColumnHeader.SubItemIndex
  578.     ListView1.Sorted = True
  579. End Sub
  580. Private Sub ListView1_DblClick()
  581. ' When the user double clicks on an item, this subroutine figures out
  582. ' which item was double clicked.
  583. ' The code makes uses of an API function (the GetCursorPos() function)
  584. ' and the control's HitTest method to figure out where the mouse was
  585. ' double-clicked and which item was clicked.
  586. ' The code is a bit involved, but you can use it as is in your code.
  587. ' The LItem variable represents the item that was double-clicked and
  588. ' you can use it to manipulate the item.
  589. Dim dPoint As POINTAPI
  590. Dim LItem As ListItem
  591.     If Not ListView1.View = lvwIcon Then Exit Sub
  592. '   Get the cursors position in screen coordinates (in pixels)
  593.     GetCursorPos dPoint
  594. '   convert screen coordinates to coordinates on the ListView control (in pixels)
  595.     X = dPoint.X - ScaleX(Me.Left + ListView1.Left, vbTwips, vbPixels)
  596.     Y = dPoint.Y - ScaleY(Me.Top + ListView1.Top, vbTwips, vbPixels)
  597. On Error Resume Next
  598. '   Now call the HitTest method to find out the item at coordinates (X, Y)
  599. '   Notice that the coordinates must be converted from pixels to twips
  600. '   The HitTest method requires that the coordinates are expressed in twips
  601.     Set LItem = ListView1.HitTest(ScaleX(X, vbPixels, vbTwips), ScaleY(Y, vbPixels, vbTwips))
  602. '   If no item was clicked, exit
  603.     If LItem Is Nothing Then Exit Sub
  604. '   If an item was clicked, then display its subitems in a message box
  605. '   Notice that the code reacts only if the items are displayed as Icons or Small Icons
  606.     If ListView1.View = lvwIcon Or ListView1.View = lvwSmallIcon Then
  607.         LItem.Selected = True
  608.         msg = LItem.Text & vbCrLf
  609.         For i = 1 To LItem.ListSubItems.Count
  610.             msg = msg & "     " & LItem.ListSubItems(i).Text & vbCrLf
  611.         Next
  612.         MsgBox msg
  613.     End If
  614. End Sub
  615. Private Sub ListView1_ItemClick(ByVal Item As ComctlLib.ListItem)
  616. ' This subroutine displays the subitems of the item that was clicked
  617. ' The code reacts only if the items are displayed in List mode
  618.     If ListView1.View = lvwList Then
  619.         msg = ListView1.SelectedItem.Text & vbCrLf
  620.         For i = 1 To ListView1.SelectedItem.ListSubItems.Count
  621.             msg = msg & "     " & ListView1.SelectedItem.ListSubItems(i).Text & vbCrLf
  622.         Next
  623.         MsgBox msg
  624.     End If
  625. End Sub
  626. Private Sub Option1_Click(Index As Integer)
  627.     ListView1.View = Index
  628. End Sub
  629.