I have a list and a button next to it that uses the selected item to perform an action. If the user does not make a choice, but presses a button, they are invited to make a choice first.
What I have below works, but is there a way where the calling method should not have an if (not selected) return statement? I want to just call the selectionFound () method from other events that are list dependent? I would like the selectionFound method to lose its temper not only by itself, but also the calling method and return control back to the user. So instead of returning true / false, as shown below, I would just like to return another keyword as well.
private void deleteData()
{
if(!selectionFound()) return;
.....
}
private bool selectionFound()
{
if (lvwInventory.SelectedIndex == -1)
{
MessageBox.Show("Please select an item first");
return false;
}
else
return true;
}