Home > Net >  GotFocus event calling repeatedly. Any way to avoid it from being repeat and execute the event only
GotFocus event calling repeatedly. Any way to avoid it from being repeat and execute the event only

Time:02-10

All this events when I click with the mouse on this controls to get focus, will repeatedly get the focus when the mouse is on the control.

Is there a way to make that in each of the Gotfocus events it will not repeat ?

private void MacTrackBar4_GotFocus(object sender, EventArgs e)
{
    timer1.Enabled = false;
    counter = 0;
}

private void MacTrackBar3_GotFocus(object sender, EventArgs e)
{
    timer1.Enabled = false;
    counter = 0;

    if (selected != null)
    {
        pictureBox1.Image?.Dispose();
        pictureBox1.Image = Image.FromFile(selected[macTrackBar3.Value - 1]);
    }
}

private void MacTrackBar2_GotFocus(object sender, EventArgs e)
{
    if (images != null)
    {
        pictureBox1.Image?.Dispose();
        pictureBox1.Image = Image.FromFile(images[macTrackBar2.Value]);
    }
}

private void MacTrackBar1_GotFocus(object sender, EventArgs e)
{
    if (images != null)
    {
        pictureBox1.Image?.Dispose();
        pictureBox1.Image = Image.FromFile(images[macTrackBar1.Value]);
    }
}

CodePudding user response:

  •  Tags:  
  • Related