|
-
Aug 28th, 2006, 07:08 AM
#1
Thread Starter
Addicted Member
setting tooltip on textbox
There is a control named as tooltip. I am using it on a form. It shows me the tooltip on textbox when I bring mouse over the textbox.
Is it possible that when the textbox gets focus(using tab key) then toolip gets displayed on textbox.
Please help and guide.
-
Aug 28th, 2006, 07:33 AM
#2
Re: setting tooltip on textbox
If you want to do something with a class the first thing you should do is look at the members of that class. The Show method of the ToolTip class is described thusly:
Overloaded. Sets the text associated with a ToolTip, and then displays it.
If you want to do something when somethign happens that means handling an event. The Enter event of a control is raised when it gets focus.
-
Feb 12th, 2008, 08:08 AM
#3
Lively Member
Re: setting tooltip on textbox
Add a form to ur project
Add some textboxes and a tooltip control to that form.
For Each Control Provide Tooltip Text.
Try the following Code
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Ctrl As Control
' The following code is assumed that u will directly add texboxes and
' other controls Directly on the form Not on any container
' like tabpage, groupbox
For i As Integer = 0 To Me.Controls.Count - 1
Ctrl = Me.Controls(i)
AddHandler Ctrl.GotFocus, AddressOf ShowToolTip
AddHandler Ctrl.LostFocus, AddressOf HideToolTip
Next
End Sub
Private Sub ShowToolTip(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Ctrl As Control = DirectCast(sender, Control)
ToolTip1.Show(ToolTip1.GetToolTip(Ctrl), Ctrl)
End Sub
Private Sub HideToolTip(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Ctrl As Control = DirectCast(sender, Control)
ToolTip1.Hide(Ctrl)
End Sub
End Class
Note: Displayed Tooltip info will not vanish as it normaly use to disappear when mouse is hovered on control.
Last edited by ComITSolutions; Feb 26th, 2008 at 09:13 AM.
Reason: Code tags added
-
Feb 12th, 2008, 08:39 AM
#4
Re: setting tooltip on textbox
 Originally Posted by ComITSolutions
Add a form to ur project
Add some textboxes and a tooltip control to that form.
For Each Control Provide Tooltip Text.
Try the following Code
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Ctrl As Control
' The following code is assumed that u will directly add texboxes and
' other controls Directly on the form Not on any container
' like tabpage, groupbox
For i As Integer = 0 To Me.Controls.Count - 1
Ctrl = Me.Controls(i)
AddHandler Ctrl.GotFocus, AddressOf ShowToolTip
AddHandler Ctrl.LostFocus, AddressOf HideToolTip
Next
End Sub
Private Sub ShowToolTip(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Ctrl As Control = DirectCast(sender, Control)
ToolTip1.Show(ToolTip1.GetToolTip(Ctrl), Ctrl)
End Sub
Private Sub HideToolTip(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Ctrl As Control = DirectCast(sender, Control)
ToolTip1.Hide(Ctrl)
End Sub
End Class
Note: Displayed Tooltip info will not vanish as it normaly use to disappear when mouse is hovered on control.
MSDN advises you to use the Enter and Leave events rather than GotFocus and LostFocus.
-
Feb 13th, 2008, 04:18 AM
#5
Lively Member
Re: setting tooltip on textbox
Thanx for the advice atheist
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|