I have a panel that contains child panels an inside the child panels I have some controls like PictureBox and label.
How can I change the back colour of just one child panel that mouse pointer is pointing with foreach
and how can I change the colour of selected panel child and how can I create child panels inside the panel that contain PictureBox
and label?
There will be problems if there is no (or small) space between Parent Control (Panel) edge and Child Control that the mouse pointer should be on the right side of the child panel to work. How can i fix this? this is my code for the mouseleave event:
private void left_panel_MouseLeave(object sender, EventArgs e)
{
foreach (Panel p in left_panel.Controls.OfType<Panel>())
{
p.BackColor = Color.Transparent;
}
}
Mouse Enter Event:
private void left_panel_MouseEnter(object sender, EventArgs e)
{
foreach (Panel p in left_panel.Controls.OfType<Panel>())
{
if (this.ClientRectangle.Contains(p.PointToClient(Control.MousePosition)))
{
p.BackColor = ColorTranslator.FromHtml("#ff0000");
}
else
p.BackColor = Color.Transparent;
}
}