c#如何清除列表视图中的数据 [英] How to clear data from list view in c#
问题描述
我有一个显示数据"按钮.单击它时,数据将显示在列表视图中.但我想清除它,然后再次单击显示数据"以显示新数据.因为我不想当我再次单击显示数据"时它重复了数据.所以我想清除旧数据以显示新数据(无重复数据).但它的标题不清楚(仍然保留标题).源代码是什么?
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 want when I click "Show data" again It duplicated data. So I want to clear old data to show new data (no duplicated data). But its header no clear (still keep header). What is the source code?
还有一个问题.我想在 c# 中访问 Datagridview 时显示表中的数据(例如,访问中的表包含:名称、职位、薪水和 c# 中的 Datagridview 也有 3 列:名称、职位和薪水通过单击按钮显示".什么是源代码?
One more question. I want to show data from table in access to Datagridview in c# (eg. table in access contain: Name, Position, salary and Datagridview in c# has 3 column also: Name, Position and Salary by click on button "Show". What is the source code?
推荐答案
在 WinForms 中:
In WinForms:
listView1.Clear();
在 WPF 中:
listView1.Items.Clear();
这篇关于c#如何清除列表视图中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!