How to add records to listview control
How to add records to listview control
API Declarations
just follow these easy steps ..
Rate How to add records to listview control
(1(1 Vote))
to add records in the listview control the syntax is::
note that the listview control has text and subitems . the first column is text and then other columns are for subitems . You can add as many subitems you want.
If you want to add records on the click event perform this action
dim items as listitem
Set items = lst.ListItems.Add(,,"item1")
items.SubItems(1) = "item2"
okk if you want to add records from the database the syntax is the same write this code on the click event.
first make the procedure listv
Dim items As ListItem
On Error Resume Next
sql = "Select * from employees"
rs.Open sql, conn, adOpenForwardOnly, adLockOptimistic
While Not rs.EOF
Set items = lst.ListItems.Add(, , rs.Fields(0))
items.SubItems(1) = rs.Fields(1)
items.SubItems(2) = rs.Fields(2)
items.SubItems(3) = rs.Fields(3)
items.SubItems(4) = rs.Fields(4)
items.SubItems(5) = rs.Fields(5)
rs.MoveNext
Wend
rs.Close
End Sub
note you can add all the fields in the database i have just shown the example of adding 5 records in the database.
rs.fields(0)
rs is the name of the recordset
fields 0 means the first field of the database
if you want to ask me any questions regarding to list view control you can email me on [email protected]
How to add records to listview control Comments
No comments yet — be the first to post one!
Post a Comment