Friday, February 10, 2012

C# how to check that ListBox has no selected items

If you want to perform some activity only when the ListBox has selected item/s, do the following:


If MultiColumn == false

if (list_box.SelectedItems.Count == 1)
{
    my_function(some_parameter);
}

If MultiColumn == true


if (list_box.SelectedItems.Count > 0)
{
    my_function(some_parameter);
}

No comments:

Post a Comment