i have some data in the listview,
maybe someone can help me..
how the script to insert all of the data in the listview into table..
help me please ..
:(
thanks,, sarah :)
i have some data in the listview,
maybe someone can help me..
how the script to insert all of the data in the listview into table..
help me please ..
:(
thanks,, sarah :)
You have to create columns of listView to dataTable (with a bit of a List<T> help), then loop through the listView to fill dataTable:
'lets assume we have 3 column in listView!!
'get columns:
Dim listOfColumns As New List(Of String)()
For Each column As ColumnHeader In listView1.Columns
listOfColumns.Add(column.ToString())
Next
'create DataTable:
Dim table As New DataTable("myTable")
For Each column As String In listOfColumns
table.Columns.Add(column, GetType(String))
Next
'fill table with datafrom listView
Dim row As DataRow
Dim i As Integer = 0
For Each item As ListViewItem In listView1.Items
row = table.NewRow()
'define for each column in listView:
row(listOfColumns(i)) = item.Text
row(listOfColumns(i)) = item.SubItems(1).Text
row(listOfColumns(i)) = item.SubItems(2).Text
table.Rows.Add(row)
Next
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.