You can develop your own control by inheriting from Label.
Here is a sample code that you can achieve your goal by using ProductText and ProductImage properties.
public class MyPictureLabel:System.Windows.Forms.Label
{
public MyPictureLabel():base()
{
this.AutoSize = false;
this.Text = ProductText;
this.BackColor = Color.White;
}
private Image _ResizedImage = null;
private Image _ProductImage = null;
public Image ProductImage
{
get { return _ProductImage; }
set { _ProductImage = value; }
}
private string _ProductText = "";
public string ProductText
{
get { return _ProductText; }
set { _ProductText = value; this.Text = value; }
}
protected override void OnMouseHover(EventArgs e)
{
base.OnMouseHover(e);
if (_ResizedImage == null || _ResizedImage.Width!=this.Width || _ResizedImage.Height!=this.Height)
{
this._ResizedImage = ProductImage.GetThumbnailImage(this.Width, this.Height, null, IntPtr.Zero);
}
if (ProductImage != null)
{
this.Text = "";
this.Image = _ResizedImage;
}
}
protected override void OnMouseLeave(EventArgs e)
{
this.Image = null;
this.Text = ProductText;
base.OnMouseLeave(e);
}
}