Adding items to a listview. Firstly, probably best to have it in report
mode, i.e. Set View = 3 - Report. Use the property pages to add, say 3
columsn to the listview, then the following piece of code will add an item
to it:
Dim oLI as ListItem
Set oLI = lvw.ListItems.Add(,,"The text of my first listitem")
oLI.SubItems(1) = "2nd col"
oLI.SubItems(2) = "3rd col"
Set oLI=Nothing
-----Original Message-----
From: Rick Dunmire [mailto:dunnies@p...]
Sent: 25 September 2001 18:42
To: professional vb
Subject: [pro_vb] Load ListView
Hello all
I am working with ListBoxes and ListViews
I want to fill a ListView with a Recordset from 1 table in a database
Here is how i get my recordset and fill a ListBox.
Private Sub Command1_Click()
strCn = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Tires\Tires.mdb"
List1.Clear
ListView1.ListItems.Clear
strsql = "SELECT * FROM Tires WHERE Mid(Tires.TireSize, 1, Len
(Text1.Text)) = Text1.Text ORDER BY Tires.TireSize"
Set cn1 = New adodb.Connection
cn1.ConnectionString = strCn
cn1.Open
Set cmd1 = New adodb.Command
cmd1.ActiveConnection = cn1
cmd1.CommandText = strsql
Set Param1 = cmd1.CreateParameter(, adVarChar, adParamInput, 40)
Param1.Value = txtFind.Text
cmd1.Parameters.Append Param1
Set Param1 = Nothing
Set rs1 = cmd1.Execute
This what i use to fill a ListBox
While Not rs1.EOF
List1.AddItem rs1.Fields("TireSize").Value
rs1.MoveNext
Wend
rs1.Close
cn1.Close
Set rs1 = Nothing
Set cn1 = Nothing
End Sub
This works well but starting from Set rs1 = cmd.Execute
how do i fill column1 of a ListView with the "TireSize" field from my
recordset?
I have been looking at samples for 2 days and i can't seem to get it just
right.
I found a sample using a Data Environment but i am not sure how to set up
the Data Environment.
I could use any help given
Thanks in advance