picturebox in super tooltip

WinForms

ComponentOne's WinForms controls

picturebox in super tooltip

  • rated by 0 users
  • This post has 4 Replies |
  • 1 Follower
  • VB.net 2008 

    I have a picturebox on my form.  How would I display the picturebox in a Super Tooltip?

     

  • You can display the image from the picture box since the image is added to your project as a resource.  Just select the image in the Solution Explorer and set Build Action to Embedded Resource.  Then you can add the image in HTML style:

    Dim tip As String

    tip = "<img src='res://image.jpg'>"

    C1SuperTooltip1.SetToolTip(Button1, tip)

    Hope that helps,
    Greg L

    Greg Lutz ComponentOne

  • Greg,

    Thank for your quick response.

    I am not using the resource because I am loading different images into the picturebox at runtime.  Any ideas of how I could display these images in the Super Tooltip?

     

  • 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.

     

     

     

    <phonl> wrote in message news:203140@10.0.1.98...

    Greg,

    Thank for your quick response.

    I am not using the resource because I am loading different images into the picturebox at runtime.  Any ideas of how I could display these images in the Super Tooltip?

     



    http://helpcentral.componentone.com/cs/forums/p/74717/203140.aspx#203140

  • Thank you Dave - your example works great.

Page 1 of 1 (5 items)