Context-sensistive Help VB.NET 2010

This section is for programmers. Please use it for all discussons on interfacing help with your applications and related subjects.

Moderators: Alexander Halser, Michael Schwarzl

Post Reply
pstanford
Posts: 1
Joined: Wed Dec 09, 2009 8:26 am

Context-sensistive Help VB.NET 2010

Unread post by pstanford »

I'm able to display context-sensitive help using the following code if I give the control focus and press F1 but I want to be able to do the same thing just by clicking the control (in this case a button).

Code: Select all

    Private Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
        Dim sHelpFile As String
        Dim sStartupPath As String
        '--- Initialize context-sensitive help ---
        sStartupPath = Application.StartupPath.ToString
        sHelpFile = Replace(sStartupPath, "\bin", "\Help") & "\FoodPlus.chm"
        With Me.HelpProvider1
            .HelpNamespace = sHelpFile
            .SetHelpNavigator(Me.RadButton1, HelpNavigator.AssociateIndex)
            .SetHelpKeyword(Me.RadButton1, "Reference")
            '.SetHelpKeyword(Me.RadButton1, "html/Reference Information.htm")
        End With

        'Help.ShowHelp(Me, HelpProvider1.HelpNamespace, "Reference", HelpNavigator.AssociateIndex)
    End Sub
I've tried uncommenting the last line as follows:

Code: Select all

    Private Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
        'Dim sHelpFile As String
        'Dim sStartupPath As String
        ''--- Initialize context-sensitive help ---
        'sStartupPath = Application.StartupPath.ToString
        'sHelpFile = Replace(sStartupPath, "\bin", "\Help") & "\FoodPlus.chm"
        'With Me.HelpProvider1
        '    .HelpNamespace = sHelpFile
        '    .SetHelpNavigator(Me.RadButton1, HelpNavigator.AssociateIndex)
        '    .SetHelpKeyword(Me.RadButton1, "Reference")
        '    '.SetHelpKeyword(Me.RadButton1, "html/Reference Information.htm")
        'End With

        Help.ShowHelp(Me, HelpProvider1.HelpNamespace, "Reference", HelpNavigator.AssociateIndex)
    End Sub
Which returns the following error:

Code: Select all

System.InvalidCastException was unhandled
  Message=Conversion from string "Reference" to type 'Integer' is not valid.
  Source=Microsoft.VisualBasic
  StackTrace:
       at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
       at FoodPlus.Reference_Management.RadButton1_Click(Object sender, EventArgs e) in C:\Users\peter.stanford.ARTEFACTION\documents\visual studio 2010\Projects\FoodPlus\FoodPlus\Reference_Management.vb:line 16
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at Telerik.WinControls.RadControl.OnClick(EventArgs e)
       at Telerik.WinControls.UI.RadButtonBase.ButtonElement_Click(Object sender, EventArgs e)
       at Telerik.WinControls.RadItem.OnClick(EventArgs e)
       at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
       at Telerik.WinControls.RadItem.DoClick(EventArgs e)
       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
       at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
       at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at FoodPlus.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.FormatException
       Message=Input string was not in a correct format.
       Source=Microsoft.VisualBasic
       StackTrace:
            at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
            at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
       InnerException: 
What am I missing here?
Post Reply