NevSoFly
asked on
Can't clear listview using .items.clear
well the truth is that I can clear the listview but when I go to repopulate the listview I get the new contents plus the old contents.
Private Sub LoadListView()
' TODO: Add code to add items to the listview based on the selected item in the treeview
Dim sql As String = ""
Me.ListView.Items.Clear()
Me.ListView.BeginUpdate()
Select Case Me.TreeView.SelectedNode.Parent.Text
Case "FSB"
sql = "SELECT * FROM tblFSB_TA WHERE Doc_Type ='FSB' AND System = '" & Me.TreeView.SelectedNode.Text & "'"
Case "TA"
sql = "SELECT * FROM tblFSB_TA WHERE Doc_Type ='TA' AND System = '" & Me.TreeView.SelectedNode.Text & "'"
Case "Manuals"
sql = "SELECT * FROM tblManuals WHERE Doc_Type ='Manual' AND System = '" & Me.TreeView.SelectedNode.Text & "'"
End Select
'Dim dt As New DataTable
Dim da As New OleDb.OleDbDataAdapter(sql, OLEConn)
da.Fill(dt)
For Each row As DataRow In dt.Rows
Dim item As New ListViewItem(row("Doc_Number").ToString())
item.SubItems.Add(row("Title").ToString())
If row("Safety") = True Then item.ForeColor = Color.Red
Me.ListView.Items.Add(item)
Next
For Each col As ColumnHeader In Me.ListView.Columns
col.Width = -2
Application.DoEvents()
Next
SetView(View.Details)
Me.ListView.EndUpdate()
Me.ToolStripStatusLabel.Text = Me.ListView.Items.Count
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER