Click here to Skip to main content
13,406,177 members (48,837 online)
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 28 Dec 2012

Textbox Balloon Tooltip .NET 2

, 28 Dec 2012
Rate this:
Please Sign up or sign in to vote.
Balloon tool tip for the text box.


Balloon tool tip for the text box. This sample code can be used to display the balloon tool tip at caret position.


The balloon tool tip was not getting displayed at the proper caret position in the text box. So did a work around for the same.

Using the code

If you want to display the balloon tool tip at the caret position. Use this sample code in your project and modify accordingly.

class CustomToolTip : ToolTip
    Control textBox;
    public CustomToolTip(Control ctrl)
        textBox = ctrl;
        this.OwnerDraw = true;
        this.IsBalloon = true;   // If wont set this to true, it will display in a rectangle.
        this.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
        this.ToolTipTitle = "Title";   // This is displayed as the Title

    public void ShowToolTip()
        this.UseAnimation = true;
        Graphics g = textBox.CreateGraphics();
        // Get the exact width of the string
        int width = (int)g.MeasureString(textBox.Text, textBox.Font).Width;
        this.Show(string.Empty, textBox, 0);
          // There is a bug in the tool tip. So display an empty string
          // for 0ms before displaying the actual string. 

       this.Show("Display String", textBox, width, textBox.Height, 3000);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Nishith Jain
Technical Lead
India India
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionMy vote of 5 Pin
BobishKindaGuy17-Jan-14 6:48
memberBobishKindaGuy17-Jan-14 6:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180221.1 | Last Updated 28 Dec 2012
Article Copyright 2012 by Nishith Jain
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid