Hello,
I'm trying to write my own control. I've got some code:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace ImageListTest
{
    public class ImageBar : System.Windows.Forms.UserControl
    {
        private System.Windows.Forms.PictureBox pb = new System.Windows.Forms.PictureBox();

        public ImageBar(String filename)
        {
            this.SuspendLayout();
            this.pb.SuspendLayout();

            this.Controls.Add(pb);

            this.pb.Size = new Size(80, 80);
            this.pb.Location = new Point(10, 10);
            this.pb.Image = Image.FromFile(filename);
            this.pb.SizeMode = PictureBoxSizeMode.StretchImage;
            this.pb.MouseDown += new MouseEventHandler(pb_OnMouseDown);
            this.pb.MouseHover += new EventHandler(pb_MouseHoverEvent);

            this.Size = new Size(100, 100);
            this.BackColor = Color.Green;
            this.Cursor = Cursors.Hand;
            this.MouseHover += new EventHandler(MouseHoverEvent);
            this.MouseLeave += new EventHandler(MouseOutEvent);

            this.pb.ResumeLayout();
            this.ResumeLayout();
        }

        private void pb_OnMouseDown(object sender, MouseEventArgs e)
        {
            this.OnMouseDown(e);
        }

        private void pb_MouseHoverEvent(Object sender, EventArgs e)
        {
            this.OnMouseHover(e);
        }

        private void MouseHoverEvent(object sender, EventArgs e)
        {
            this.BackColor = Color.Azure;
        }

        private void MouseOutEvent(Object sender, EventArgs e)
        {
            this.BackColor = Color.Green;
        }
    }
}

That works fine, but I've got one problem - when I move mouse from outside of PictureBox on the PictureBox my control blinks (first MouseOutEvent is triggered, and then pb_MouseHoverEvent). How to stop the blinking? In other words, how to make PictureBox a real part of my control?

Try disabling the picturebox.

Thank You for reply, it helped.

This question has already been answered. Start a new discussion instead.