I've just started to learn basic programming and got an assignment to program a search box.
The problem I have is that the clear button clears the whole thing in the list view box including column headers. I want just the printed contents gone, and those column headers to remain. Here's my code.
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);
}
Thanks for reading!
Use Items.Clear();
Like this : listview.Items.Clear();
Hope this works :)