private Rectangle rectP; rectP = new Rectangle(panel1.Location, panel1.Size); private bool isInPanel; private void panel_MouseMove(object sender, MouseEventArgs e) { if (rectP.Contains(e.Location)) isInPanel = true; else isInPanel = false; }