How can I clean (delete all entries) in a listbox on a form?
I am programming with Visual C# .NET.
Thanks for all your help in advance!
Printable View
How can I clean (delete all entries) in a listbox on a form?
I am programming with Visual C# .NET.
Thanks for all your help in advance!
If you're actually looking for a winapi solution then LB_RESETCONTENT is the message for you.
Otherwise, please direct your questions to the proper (c# board) board.
No, I am looking for .NET solution...
Anyway - isn't Windows Programming board board for any Windows Programming (from Win32 API to .NET Framework - Windows.Forms) ?
Can moderator please move this topic to C# board?
I fired up the .NET documentation and used the index to go to ListBox class (System.Windows.Forms). There was no obvious clear method defined directly on the ListBox class, so I looked for an Items property. Sure enough, the ListBox class has an Items property which returns a ListBox.ObjectCollection object. One of the methods availabe on this class is Clear. So, in the end, we get:
Code:listbox1.Items.Clear()
Thanks!