I’m trying to avoid having the same code in multiple places. Which event handler would let me to check if I have any items in my ListBox on the fly?
This is how I check if I have any items in ListBox:
if (lbMessage.Items.Count > 0)
{
btnStart.Enabled = true;
}
else
{
btnStart.Enabled = false;
}
There is no event for such an occurrence (for a list of available events, check out the MSDN Documentation for this control). To make your code more re-usable, you could use a property, such as:
Then you can just call that property each time you want to check if there are any items.