I have one problem, i need to stop all the timers running with one button click but i can't i started with flowLayoutPanel1.Controls.Clear();
but it jut clrear the panel and the timers keep running in background.
Now my code is like this one bellow:
private void btnClearTimersFlowPanel_Click(object sender, EventArgs e)
{
if (flowLayoutPanel1.Controls.Count > 0)
{
if (MessageBox.Show("You want to clear?", "Clear", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
return;
else
{
foreach (UC control in flowLayoutPanel1.Controls.OfType<UC>())
{
if (control is UserControl)
{
time.Timer.Stop();
}
}
flowLayoutPanel1.Controls.Clear();
}
}
else
return;
}
But it just don't stop the timers i don't know what i can do to stop them, i need some help with this please.
The UC
is the name of my UserControl