Wednesday, August 11, 2010

How to populate a listview and datagrid?

please help me am starter in programming with vb and would like the world to help me on how to populate a listview and a datagrid with data from a database. send me a sample codes and i will apprecitae as we help each other.How to populate a listview and datagrid?
I'm posting a simple example here where u can start lerning on list view.


I think as a starter this would help u.





' Set the View


ListView1.View = lvwReport





' Add the columns


With ListView1.ColumnHeaders


.Add , , ';Name';


.Add , , ';Surname';


.Add , , ';Address';


End With





With ListView1.ListItems


' Add the normal text


.Add , , ';Fred';


.Add , , ';Sarah';


.Add , , ';Paul';


End With





With ListView1


' Add a value to the second column to the first item on the list (';Fred';)


' (1) = First item on list


.ListItems(1).SubItems(1) = ';Crowley';


.ListItems(2).SubItems(1) = ';Ives';


.ListItems(3).SubItems(1) = ';Smith';


' Add a value to the third column to the first item on the list (';Fred';)


' (1) = First item on list


.ListItems(1).SubItems(2) = ';16 Liverpool Lane';


.ListItems(2).SubItems(2) = ';102 England Street';


.ListItems(3).SubItems(2) = ';1 Baker Street';


End With

No comments:

Post a Comment