【发布时间】:2021-10-15 16:37:52
【问题描述】:
我刚刚开始学习基本编程,并得到了一个为搜索框编程的任务。
我遇到的问题是清除按钮清除了列表视图框中的整个内容,包括列标题。我只希望打印的内容消失,并且保留那些列标题。这是我的代码。
private void button2_Click_1(object sender, EventArgs e)
{
Action<Control.ControlCollection> func = null;
func = (controls) =>
{
foreach (Control control in controls)
if (control is ListView)
(control as ListView).Clear();
else
func(control.Controls);
};
func(Controls);
}
感谢阅读!
【问题讨论】:
-
在旁注中,您可以在不循环表单上的所有控件的情况下完成此操作,只需执行
listivewName..Items.Clear() -
感谢您的帮助!我试过了,这一切都归功于你的帮助。祝你有美好的一天!
标签: c# listview columnheader