清除列表视图而不删除 VB.Net 中的列?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18958770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 15:11:03  来源:igfitidea点击:

Clearing list view without deleting columns in VB.Net?

vb.net

提问by user2765899

I need help regarding list view. I'm trying to remove the records in my list view but when I try to use lvRecords.Clear() it also removes the columns that I need. I just need to clear the records not the columns. :(

我需要有关列表视图的帮助。我正在尝试删除列表视图中的记录,但是当我尝试使用 lvRecords.Clear() 时,它也会删除我需要的列。我只需要清除记录而不是列。:(

回答by Steven Doggart

According to the MSDN, the ListView.Clearmethod

根据MSDN,该ListView.Clear方法

Removes all items and columnsfrom the control.

从控件中删除所有项目和列

To clear just the items, you need to call the Clearmethod on the Itemsproperty. Try this instead:

要仅清除项目,您需要调用属性Clear上的方法Items。试试这个:

lvRecords.Items.Clear

回答by Steve

Put the column setup in a separate method and then once you clear it call the setup method

将列设置放在单独的方法中,然后清除它后调用设置方法