C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

picturebox in super tooltip

rated by 0 users
This post has 4 Replies | 1 Follower

Top 150 Contributor
Posts 33
phonl Posted: Fri, Mar 21 2008 1:13 PM

VB.net 2008 

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

 

Top 25 Contributor
Posts 585
C1_GregL replied on Fri, Mar 21 2008 5:12 PM

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
Top 150 Contributor
Posts 33
phonl replied on Mon, Mar 24 2008 9:23 AM

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?

 

Top 25 Contributor
Posts 666

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

Top 150 Contributor
Posts 33
phonl replied on Thu, May 22 2008 11:05 AM

Thank you Dave - your example works great.

Page 1 of 1 (5 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.