Introduction
Balloon tool tip for the text box. This sample code can be used to display the balloon tool tip at caret position.
Background
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; this.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.ToolTipTitle = "Title"; }
public void ShowToolTip()
{
this.UseAnimation = true;
Graphics g = textBox.CreateGraphics();
int width = (int)g.MeasureString(textBox.Text, textBox.Font).Width;
g.Dispose();
this.Show(string.Empty, textBox, 0);
this.Show("Display String", textBox, width, textBox.Height, 3000);
}
}