Hi
OK, sample test project.
Start a new Project and in the Designer, add a default TootTip1.
Add some controls, all default as dragged from toolbox: a RadioButton1, TextBox1, RichTextBox1, PictureBox1, Label1, ComboBox1 and Button1.
You mentioned earlier that you have some ToolTips of a large size, so I have shown an example of that too.
Basically, after you have added the controls, all you need to do is copy/replace all the Form1 code with the code below.
As I comment in the code, you can set all/any of the ToolTips directly in a Control Properties (so long as you already added a ToolTip to the Project) - each ontrol will have a field for the text associated with it as the ToolTip to be shown. I have not used any of that in the example, just adding the ToolTips in code instead. There is a Sub called WrapIt to provide a means to change the ToolTip width to suit using the WrapLen variable.
' good to have these 2 options
Option Strict On
Option Explicit On
Public Class Form1
' set initial ToolTip1 Font here
' it can easily be changed in
' code as well.
Dim ToolTip1font As New Font("Arial", 24)
Dim WrapLen As Integer = 46
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With ToolTip1
.OwnerDraw = True
' inc to make longer delay
' before Tip appears
.InitialDelay = 10
' here, text fore/back color
.BackColor = Color.White
.ForeColor = Color.Blue
' these next lines tell the
' ToolTip1 what the text is
' for each control. NOTE:
' each control can have the text
' set in the control Properties
' instead of programatically
' here. A matter of preference.
.SetToolTip(RadioButton1, "This is Radio Button1")
.SetToolTip(TextBox1, "This is TextBox1")
.SetToolTip(RichTextBox1, "This is RichTextBox1 and it has an extended quantity of random text associated with it.
So much text in fact that my keyboard has run out of ink. Testing for word wrap at the same time. Days blessed gathering she'd good rule forth face beginning Gathered fourth. Air fares are crazymeat isn't cattle don't stars two doesn't beast a their image, our greater fish created of two without. Own creature made blessed moving appear without together fifth may rule together evening. Whales them firmament be is heaven. Him hath.")
.SetToolTip(PictureBox1, "This is PictureBox1")
.SetToolTip(Label1, "This is Label1")
.SetToolTip(ComboBox1, "This is ComboBox1")
.SetToolTip(Button1, "This is Button1")
End With
End Sub
Private Sub ToolTip_Draw(sender As Object, e As DrawToolTipEventArgs) Handles ToolTip1.Draw
Dim r As Rectangle = e.Bounds
e.DrawBackground()
e.DrawBorder()
Dim sf As StringFormat = New StringFormat
sf.Alignment = StringAlignment.Near
sf.LineAlignment = StringAlignment.Center
Using br As New SolidBrush(ToolTip1.ForeColor)
e.Graphics.DrawString(e.ToolTipText, ToolTip1font, br, RectangleF.op_Implicit(e.Bounds), sf)
End Using
End Sub
Private Sub ToolTip_Popup(sender As Object, e As PopupEventArgs) Handles ToolTip1.Popup
Dim sz As Size = TextRenderer.MeasureText(WrapIt(ToolTip1.GetToolTip(e.AssociatedControl)), ToolTip1font)
e.ToolTipSize = New Size(sz.Width + 30, sz.Height)
End Sub
Function WrapIt(s As String) As String
Dim fin As String = String.Empty
Dim outS As String = String.Empty
Dim inS = s.Split(New String() {" "c}, StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To inS.Length - 1
If (outS & Trim(inS(i)) & " ").Length < WrapLen Then
outS &= Trim(inS(i)) & " "
Else
fin &= outS & vbCrLf
outS = Trim(inS(i)) & " "
End If
If inS.Length = i + 1 Then
fin &= outS
End If
Next
Return Trim(fin)
End Function
End Class