please tell me how to load my database values in listview control

karthikeyan

Member
Joined
Oct 22, 2005
Messages
12
Programming Experience
Beginner
hi
i am using oracle connection to connect database with vb.net.
i am using listview control in my form
i want my table datas has to be filled in my listview while loading the form
please can u provide coding for that
 
The easiest way would be to download the Quantum Windows Forms Components (WFC) library (see my signature for a link) and use their ExtendedListView control, which supports data-binding. That way all you have to do is to assign your DataTable to the DataSource property. Otherwise you have to loop through the rows of the dataTable and create each individual item and subitem and add them to the ListView.
 
Below is the way to add subitem to the ListView if you do not want to use Quantum Windows Forms Components library:

' SQL string
SQL = "SELECT * FROM tblName"
dr = ExecuteReader(SQL)
While dr.Read
Dim item1 As New ListViewItem(dr("UserName").ToString())
' Place a check mark next to the item.
item1.Checked = False
item1.SubItems.Add(dr("UserID").ToString())
.
.
.
ListView1.Items.AddRange(
New ListViewItem() {item1})
End While
dr.Close()
 
Back
Top