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.

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 5 Years Ago by ddanbe: n/a

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

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.

Comments
You are absolutely right!

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 5 Years Ago by ddanbe: typo

This question has already been answered. Start a new discussion instead.