-1

The program practically executes the mouse leave event after the user clicks and leaves the mouse from the control, if I do not want to run the mouse leave event when the click is executed.

    private void LblNoeMelk_MouseHover(object sender, EventArgs e)
    {
        HoverColor.LblHover(LblNoeMelk);
    }

    private void LblNoeMelk_MouseLeave(object sender, EventArgs e)
    {
        
        LeaveColor.LblLeave(LblNoeMelk);
    }

    private void LblNoeMelk_Click(object sender, EventArgs e)
    {
        HoverColor.LblHover(LblNoeMelk);
    }
Sam
  • 3
  • 2

2 Answers2

0

You can check using a variable to check check that variable when the unclick event is running.

For example, when the button is clicked, the value of flag becomes 1, and when we unclick, and if the value of flag is 1, it does nothing.

Note:change the value of the flag at the end of the unclick method to 0.

0

Implementing @Saeed solution in code-

bool isLabelClicked = false;

private void LblNoeMelk_MouseHover(object sender, EventArgs e)
    {
        HoverColor.LblHover(LblNoeMelk);
    }

    private void LblNoeMelk_MouseLeave(object sender, EventArgs e)
    {
        if(isLabelClicked ==true)
        {
              isLabelClicked = false;
              return;
        }
        LeaveColor.LblLeave(LblNoeMelk);
    }

    private void LblNoeMelk_Click(object sender, EventArgs e)
    {
        HoverColor.LblHover(LblNoeMelk);
        isLabelClicked = true;
    }
umesh shukla
  • 139
  • 3
  • 13