I have a checkBox in my Windows application called "Continuous". When user checks this and clicks "Process" button, application will process all the items in the listBox. However if user does not check this box it will only process the first one in the list.
In my Process method I want to write an if condition to check the checkBox checked and execute the foreach loop otherwise execute just the first item.
Here is my code
private void btnProcess_Clicl()
{
bool bDone = false;
while(!bDone)
{
LoadList(); //This will load the list from database into listBox
if(listBox.items.Count > 0)
{
ProcessList();
}
if(!chkBox.Checked)
bDone = true;
}
}
I've implement the foreach loop to process list in ProcessList() method. Is there anyway to avoid executing LoadList() method from executing if the user checks continuous checkBox? LoadList() will populate the listBox from database.
ProcessList()once if the checkbox is checked, or is it that you want to avoid loading the entire list from the db if it isn't checked?