I have a usercontrol with a label and a picturebox on it, on the usercontrol itself there is a mouseleave event which change the background color of the usercontrol.
My question is, how do i either make the child controls react to this or ignore it - as it is now the mouseleave will be triggered when the mouse enters forinstance the label :-(
Regards

Mouse leave event, on child controls
dotnetto
private void UserControl1_Load( object sender, EventArgs e )
{
this.MouseLeave += new EventHandler(Control_MouseLeave);
foreach(Control control in Controls)
{
control.MouseLeave += new EventHandler(Control_MouseLeave);
}
}
private void Control_MouseLeave( object sender, EventArgs e )
{
// TODO: Handle the mouse leave.
}
Swarna
if( !this.BackColor.Equals( Color.Red ) )
{
this.BackColor = Color.Red;
}
When you set a lot of colors you can also use the LockWindowUpdate api or the SuspendLayout method of the Control class.
SithKitty
I have tried this, put the usercontrols event on the child controls too, but this creates a bit of flicker with the colors as it triggers from usercontrol onto child control.
Maybe this is the correct soultion, I was just hoping for something a little better.