How to clear data from list view in c#

前端 未结 8 768
一个人的身影
一个人的身影 2021-01-07 08:32

I have a button \"Show data\". When click it, data will display in list view. But I want to clear it and then click \"Show data\" again to display new data. Because I don\'t

相关标签:
8条回答
  • 2021-01-07 09:20

    put this at the top of your "Show Data" button's click event.

    private void showData_Click(object sender, EventArgs e)  // done
            {
                 listViewData.Items.Clear();
                 // your code
            }
    
    0 讨论(0)
  • 2021-01-07 09:28

    for listView on clicking first clear the list and then add items: like below

        private void button9_Click(object sender, EventArgs e)
        {
            listView1.Clear();
            listView1.Items.Add("Item1");
            listView1.Items.Add("Item2");
            listView1.Items.Add("Item3");
            listView1.Items.Add("Item4");
            listView1.Items.Add("Item5");
        }
    

    for your second question try below link:

    How to show data from Access on C#?

    0 讨论(0)
提交回复
热议问题