PictureBox Tooltip changing C#

BrandNewDev picture BrandNewDev · Feb 9, 2011 · Viewed 31.3k times · Source

Ok so I am a complete beginner and have managed to put together a small app in C# where I enter a username in a textbox and the application gets the avatar of that username and displays it in a picturebox.

What i want to do is have a tooltip show the username that was typed in the textbox when mouse hovers over the loaded avatar. it should change each time a new avatar is loaded. I know how to use tooltips the normal way but this is a bit complex for me. Any help will be appreciated.

Thanks.

Answer

Joe picture Joe · Feb 9, 2011

Add a hover event to your picturebox with the following code.

private void pictureBox1_MouseHover(object sender, EventArgs e)
{
    ToolTip tt = new ToolTip();
    tt.SetToolTip(this.pictureBox1, "Your username");
}