0

hi,

i have wrote the following code....

private void button_MouseEnter(object sender, EventArgs e)
        {
           
            if ( button.Enabled== false)
                label1.Text = "Please Select the area to scan";
            else
                label1.Text = "It will scan the specified area";
        }

and used mouse enter handler.The problem i am getting is it give me the value of else case when the button is enabled.if the button is disables it didn't show me if part...
Please help me to solve that problem
Thanks in advance.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by ddanbe
Featured Replies
  • I don't think the problem is regarding his calling object. I [I]believe[/I] what is happening, is that when you disable the button, the events for that button are also disabled. So when you disable the button, you are no longer processing the MouseEnter event. A quick way to test this, … Read More

  • 1
    ddanbe 2,525   6 Years Ago

    Yes there is. Redesign your project. Why perform some (any) action while hovering over a disabled button. Disable for a Button should mean: "He, ignore me!" Read More

0

have you tried:

private void button_MouseEnter(object sender, EventArgs e)
        {
           Button myButton = sender as Button;
            if ( myButton.Enabled== false)
                label1.Text = "Please Select the area to scan";
            else
                label1.Text = "It will scan the specified area";
        }

Edited by ddanbe: n/a

Votes + Comments
++rep. Post is positive so far.
its not entring in the event and u r giving me event hint
3

I don't think the problem is regarding his calling object.

I believe what is happening, is that when you disable the button, the events for that button are also disabled. So when you disable the button, you are no longer processing the MouseEnter event.

A quick way to test this, is to place a BreakPoint on your if statement and enter the button with it enabled and then disabled. If the event is being called, the code execution will stop and you will be pushed back into your development environment. The line containing the breakpoint will be highlighted yellow.

Votes + Comments
You are absolutely right!
1

Yes there is. Redesign your project. Why perform some (any) action while hovering over a disabled button. Disable for a Button should mean: "He, ignore me!"

Edited by ddanbe: typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.