in

C1 Community

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

picturebox in super tooltip

Last post 05-22-2008 11:05 AM by phonl. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-21-2008 1:13 PM

    • phonl
    • Top 500 Contributor
    • Joined on 03-14-2006
    • Posts 14

    picturebox in super tooltip

    VB.net 2008 

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

     

  • 03-21-2008 5:12 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: picturebox in 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

    Filed under: ,
  • 03-24-2008 9:23 AM In reply to

    • phonl
    • Top 500 Contributor
    • Joined on 03-14-2006
    • Posts 14

    Re: picturebox in super tooltip

    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?

     

  • 05-07-2008 3:51 PM In reply to

    Re: picturebox in 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

  • 05-22-2008 11:05 AM In reply to

    • phonl
    • Top 500 Contributor
    • Joined on 03-14-2006
    • Posts 14

    Re: picturebox in super tooltip

    Thank you Dave - your example works great.

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