Reputation: 119
I have panel on main form in disabled state I want to enable it by mouse enter event. How can I?
private void pnlOne_MouseEnter(object sender, EventArgs e)
{
pnlOne.Enabled = true;
pnlOne.Visible = true;
}
I try above one but it not working...
Upvotes: 0
Views: 924
Reputation: 3065
You can try a MouseMove
event on Panel
's parent control. In that you can check cursor position and if cursor is on Panel
, you can enable Panel
.
private void PANELS_PARENT_CONTROL_MouseMove(object sender, MouseEventArgs e)
{
if (e.Location.X > pnlOne.Location.X &&
e.Location.X < (pnlOne.Location.X + pnlOne.Width) &&
e.Location.Y > pnlOne.Location.Y &&
e.Location.Y < (pnlOne.Location.Y + pnlOne.Height))
{
pnlOne.Enabled = true;
pnlOne.Visible = true;
}
else
{
pnlOne.Enabled = false;
pnlOne.Visible = false;
}
}
Upvotes: 0
Reputation: 222552
If you have Disabled your control mouse event wont get fired. You cant do this.
Even if you enabled some other events,Check whether your panel is in the front . Use bring to front in the designer. Reason could be another container control is in the middle.
Upvotes: 1