Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Alright, so I have added the "Help button" to the caption bar of my program, but I am unsure how to use it. Once the button is pressed it changes the cursor to a little question mark and then the user is supposed to click a button and it will display some help text or something. But my question is what is the code for this "Help Button"?
I tried using the below code and it displays that textbox when the help button is pressed and then the user clicks something, but I need to handle different help texts for each button that the help button is used on.
VB
Private Sub Form1_Help(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.HelpRequested
    MsgBox("hi")
End Sub

Thanks! :)
Posted

Try using the Control.HelpRequested[^] event for each control.
 
Share this answer
 
Comments
NY Andrew 14-Aug-11 15:27pm    
Thank you! It works perfectly! That was exactly what I was looking for!
Wendelius 14-Aug-11 15:48pm    
That's great! Glad it helped :)
NY Andrew 14-Aug-11 16:35pm    
Sorry for having to ask you for some help.. But in that example that you have mentioned it puts the text into a TextBox, but I am trying to show that text in a pop up balloon tip. Any further ideas?
Once again, thank you!
I added another answer since I felt this is a different question.

Anyway, perhaps the easiest way is to use tooltip. For example try the following in your HelpRequested event:
VB
Dim toolTip1 As New ToolTip()

toolTip1.Show("Some text goes here", Me.Button1, 1000)


More info on ToolTip:ToolTip Class[^]

There are also plenty of great articles at CodeProject for different kinds of balloons etc. For example this one Balloon Tips Galore![^] has both c# and vb implementations. Don't know how it works with newer environments but it may be worth a try.
 
Share this answer
 
Comments
NY Andrew 14-Aug-11 17:17pm    
hmm.. Not really working, but eventually I'll get something to work. I'm looking through those articles right now. Thanks for all the helpful info!!! :)
Wendelius 14-Aug-11 17:24pm    
What was the problem? No tooltip showing?
NY Andrew 14-Aug-11 17:28pm    
Well, the tooltip is showing, but it shows TWO of the same tooltip.. I tried closing the tooltip when the first tooltip fades away but no luck. When I click the help button on the title bar then click the button it shows the 2 tooltips, and then when I move the mouse away and then back on it it shows the tooltip when it is not supposed to show the tooltip unless the help button has been pressed.
Wendelius 14-Aug-11 17:52pm    
Yes, funny. It doesn't seem to play nicely. I noticed same kind of comments in MSDN documentation. I think you can overcome that with something like:

Imports System.Timers
Public Class Form1

Private tooltipTimer As System.Timers.Timer = New System.Timers.Timer(2000)
Private toolTip1 As New ToolTip()
Private toolTipControl As Control
Delegate Sub TooltipHideCallback()


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler tooltipTimer.Elapsed, AddressOf tooltipTimerElapsed
End Sub
Private Sub tooltipTimerElapsed(ByVal source As Object, ByVal e As System.Timers.ElapsedEventArgs)
tooltipTimer.Stop()
If toolTipControl.InvokeRequired Then
Dim delegateVar As New TooltipHideCallback(AddressOf HideToolTip)
Me.Invoke(delegateVar)
Else
HideToolTip()
End If

End Sub

Private Sub HideToolTip()
toolTip1.Hide(toolTipControl)
End Sub

Private Sub Button1_HelpRequested(ByVal sender As System.Object, ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles Button1.HelpRequested
toolTipControl = Me.Button1
toolTip1.Show("Some text goes here", toolTipControl, 5000)
tooltipTimer.Start()
End Sub
End Class
NY Andrew 14-Aug-11 17:59pm    
Well this would be more on the right track, although after the HelpButtons tooltip is gone, if you move the pointer back over that same button, it is STILL showing that text without the user having to push the helpbutton..

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900