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.

Recommended Answers

All 4 Replies

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";
        }
commented: its not entring in the event and u r giving me event hint +0
commented: ++rep. Post is positive so far. +12

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.

commented: You are absolutely right! +8

Is there any solution?

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!"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.