|
-
Dec 13th, 2003, 09:49 PM
#1
Thread Starter
Hyperactive Member
ADO and Listview **RESOLVED**
Hello, I have a database in ADO. I want to populate a listview with every record in the database. The listview will only have 3 columns with headers "field1", "field2", "field3". Each "field" will contain the data from the fields, of the same name in the database. In other words, Column "Field1" will have data from the field in the database "Field1". I did a search and did not really find what I needed.
Last edited by LostAngel; Dec 16th, 2003 at 01:59 AM.
Code:
If LostAngel.Tag = "Programming" then
LostAngel.Caption = "Awake"
Else
LostAngel.Caption = "Dreaming of Code"
End If
-
Dec 14th, 2003, 10:53 PM
#2
Thread Starter
Hyperactive Member
Code:
If LostAngel.Tag = "Programming" then
LostAngel.Caption = "Awake"
Else
LostAngel.Caption = "Dreaming of Code"
End If
-
Dec 15th, 2003, 03:08 AM
#3
What code do you have so far to start with? Or something you found?
-
Dec 15th, 2003, 01:03 PM
#4
Thread Starter
Hyperactive Member
When my form loads, it calls the following.
VB Code:
If Adodc1.Recordset.BOF = False Then
Adodc1.Recordset.MoveFirst
End If
List1.Clear 'clears list so it makes a new one and does not just add cars
Do While Adodc1.Recordset.EOF = False 'do it unless its eof
List1.AddItem Adodc1.Recordset!PartName 'adds the 'partname' field
Adodc1.Recordset.MoveNext
Loop 'loops around
That uses the listbox, I would like to change it to a listview. As you can see though, this will only add the field "PartName". I know how to add new columns on a listview, but wanted to know how to populate each column from a different field in a record. Sort of like what the above code does, but for each of the three fields.
Code:
If LostAngel.Tag = "Programming" then
LostAngel.Caption = "Awake"
Else
LostAngel.Caption = "Dreaming of Code"
End If
-
Dec 16th, 2003, 12:33 AM
#5
To create the ListView columns use:
VB Code:
ListView1.View = lvwReport
Set clmX = ListView1.ColumnHeaders.Add(1, , "Field1", 1000)
Set clmX = ListView1.ColumnHeaders.Add(2, , "Field2", 1000)
Set clmX = ListView1.ColumnHeaders.Add(3, , "Field3", 1000)
Then to populate use:
VB Code:
If Adodc1.Recordset.BOF = False Then
Adodc1.Recordset.MoveFirst
End If
ListView1.ListItems.Clear
Do While Adodc1.Recordset.EOF = False
Set itmX = ListView1.ListItems.Add
itmX = Adodc1!Field1
itmX.SubItems(1) = Adodc1!Field2
itmX.SubItems(2) = Adodc1!Field3
Adodc1.Recordset.MoveNext
Loop
-
Dec 16th, 2003, 01:58 AM
#6
Thread Starter
Hyperactive Member
Thanks for the code, earlier tonite I managed to figure it out, though my internet was down so I could not put resolved on my topic.
Code:
If LostAngel.Tag = "Programming" then
LostAngel.Caption = "Awake"
Else
LostAngel.Caption = "Dreaming of Code"
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|