PDA

View Full Version : Control Tip Text



ksilenio
11-30-2019, 01:52 PM
Hi to all . How do I add a row in the control tip text ? scr(52) 25517 Ragards Kostas

SamT
11-30-2019, 04:02 PM
I don't think you can.

I can think of a long work around. In fact. I used something similar when I wanted an instruction label overlaid the control. I used input validation to position and show the label(s), and the Label_Click Event to unload it. But I think you will need to use a less User friendly method.

You can use MouseDown + Button|+Ctrl|+Alt|+Shift to load the label.

p45cal
12-01-2019, 09:22 AM
Taking on SamT's idea, see attached.

Uses labels whose Visible property is originally set to False.
Textbox Mouseover event to show a label
Userform Mouseover event to hide them.

ksilenio
12-01-2019, 01:45 PM
Hi Thank you for your answer and for the example ,but where can i'll find the three little dots, so to make the multi line row?
Regards

p45cal
12-01-2019, 02:13 PM
Those 3 dots are an ellipsis which I get by holding down the left Alt key and typing 0133 on the number pad.
However, this has nothing to do with making this multiline.
Use Ctrl + Return to get a new line on a label control.

ksilenio
12-01-2019, 02:41 PM
Thank you very much for your help.
The last question (i hope) is how can i get the (Ctrl + Return) in run time, so to create a dynamic label? and i want to visible the label in some time and when the time expire ,the label be visible=false again
Regards

p45cal
12-01-2019, 04:05 PM
eg.:

Label1.Caption = "First line" & vbLf & "SecondLine" & vbLf & "third line"



re:
to visible the label in some time and when the time expire ,the label be visible=false againRegards
Difficult/convoluted!

SamT
12-01-2019, 05:15 PM
i want to visible the label in some time and when the time expire ,the label be visible=false again
not hard, convoluted, not very User Friendly compared to mouse click and mouseMove

Paul_Hossler
12-01-2019, 07:10 PM
You can Add and Remove the 'tooltip' labels at run time




Option Explicit


Dim bTooltip As Boolean




Private Sub UserForm_Initialize()
bTooltip = False
End Sub




Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call AddToolTip(TextBox1, "This is line 1" & vbLf & "This is line 2")
End Sub




Private Sub TextBox2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call AddToolTip(TextBox2, "This is aaaaaaaaaaaaaaaaaaaaaaaaaaaaa line 3" & vbLf & "This is bbbbbbbbbbbbbbbbbbb line 4" & vbLf & _
"This is cccccccccccccccc line 5" & vbLf & "This is dddddddd line 6")
End Sub




Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim oControl As MSForms.Control

If Not bTooltip Then Exit Sub

For Each oControl In Controls
If TypeName(oControl) = "Label" Then
If oControl.Name Like "*_Tooltip" Then
Me.Controls.Remove oControl.Name
End If
End If
Next

bTooltip = False
End Sub




Private Sub AddToolTip(ctrl As MSForms.Control, Tooltip As String)
Dim oLabel As MSForms.Label

Set oLabel = Me.Controls.Add("Forms.Label.1", ctrl.Name & "_Tooltip", True)


With oLabel
.BackColor = &HE1FFFF
.Caption = Format(Time, "hh:mm:ss") & vbLf & vbLf & Tooltip
.Left = ctrl.Left + 10
.Top = ctrl.Top + 10
.BorderStyle = fmBorderStyleSingle
.Enabled = True
.WordWrap = False
.AutoSize = True
End With


bTooltip = True


End Sub


Private Sub CommandButton1_Click()
Me.Hide
Unload Me
End Sub

ksilenio
12-02-2019, 03:36 PM
Thank you all for your answers
Regards