There is no such direct way of
setting image of source dynamically at run time. However there is a workaround
to get the desired behavior.
If image of picture box is
changing at run time we may create a new instance of C1ToolTip every time when
image changes and this new object can be used to set a new image in tooltip.
Following is code snippet which
changes image at run time and sets tooltip according to new image of picture
box.
------------------Start
Code--------------------
public partial class Form1 :
Form
{
public Form1()
{
InitializeComponent();
}
string tip;
C1.Win.C1SuperTooltip.C1SuperTooltip ttp;
private void Form1_Load(object sender, EventArgs e)
{
//Set image on form load
this.pictureBox1.Image = Image.FromFile("C:\\img1.jpg");
SetTooltip(this.textBox1);
}
private void SetTooltip(Control cntrl)
{
if (this.pictureBox1.Image != null)
{
if (ttp != null)
{
//Dispose old object
ttp.Dispose();
}
ttp = new C1.Win.C1SuperTooltip.C1SuperTooltip();
ttp.Images.Add("PboxImg", this.pictureBox1.Image);
tip =
"<img src='res://PboxImg'>";
//Set tooltip
ttp.SetToolTip(cntrl, tip);
}
}
private void button1_Click(object sender, EventArgs e)
{
//Change image on button click
this.pictureBox1.Image = Image.FromFile("C:\\img2.jpg");
SetTooltip(this.textBox1);
}
private void button2_Click(object sender, EventArgs e)
{
//Change image on button click
this.pictureBox1.Image = Image.FromFile("C:\\img4.jpg");
SetTooltip(this.textBox1);
}
}
------------------Code
End-----------------
I hope this helps.
-Dave.