Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear Listview Items and Subitems

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
I have a two column ListView control. On the click of a button it is populated with information. This data can change at anytime. If the user clicks the button again, I want to be able to clear the main column and the subitem in the second column.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Try:

ListView1.Items.Clear()

I hope this helps.

Ron

Ron Repp
 
I did, but it does not seem to clear the SubItems. Thanks.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Strange, seems to work fine for me:
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.Columns.Add("Column1")
        ListView1.Columns.Add("Column2")
        ListView1.Columns.Add("Column3")
        Dim lvi As New ListViewItem
        lvi.Text = "Item1"
        lvi.SubItems.Add("Item2")
        lvi.SubItems.Add("Item3")
        ListView1.Items.Add(lvi)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListView1.Items.Clear()
    End Sub


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Yes it does. I was using the listview item clear method. I think when I used the listview clear vs the listview item clear, it was causing me problems because I had predefined my columns in the properties window and it was erasing my column headings. I like this way above that adds the columns via code. I will try this and am sure that it will work.

Thanks again.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top