I am after a statement that will clear all strings / data that is currently in a listBox, I have tried:
private void cleanlistbox(object sender, EventArgs e) { listBox1.ResetText(); }
Clear ListBox With the DataSource = null Approach in C# The best solution for this would be to specify the ListBox. DataSource property equal to null to remove the data source and then use the ListBox. Items. Clear() function to clear the previous items in the list box.
ClearList() and SelectAll() functions The ClearList() function deselects all items in a multi-select list box, or sets the value to Null if the list box is not multi-select. The SelectAll() function selects all the items in a multi-select list box.
For clearing the listbox you are right in using listbox. Item. Clear() .
What about
listbox1.Items.Clear();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With