I need to select all items in a ListBox when a CheckBox is clicked. Is it possible to select all items in the ListBox using a single line of code? Or will I have to loop thr
I know this question is tagged with .NET 2.0 but if you have LINQ available to you in 3.5+, you can do the following:
ASP.NET WebForms
var selected = listBox.Items.Cast().All(i => i.Selected = true);
WinForms
var selected = listBox.SelectedItems.Cast().ToArray();