Thanks very Much that did the trick. I tried to translate the C# into Vb.net But I'm getting the following error.
Unable to cast object of type 'F1_Help.AdskCommandHandler' to type 'System.Windows.Input.ICommand'.
Any Help would be much appreciated.
<CommandMethod("CRB")> _
Public Sub CRB()
Dim ribCntrl As Autodesk.Windows.RibbonControl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl
Dim ribTab As RibbonTab = New RibbonTab
ribTab.Title = "F1 Help Test"
ribTab.Id = "My_Tab_ID"
ribCntrl.Tabs.Add(ribTab)
Dim ribSourcePanel As Autodesk.Windows.RibbonPanelSource = New RibbonPanelSource
ribSourcePanel.Title = "Controls"
Dim ribPanel As RibbonPanel = New RibbonPanel
ribPanel.Source = ribSourcePanel
ribTab.Panels.Add(ribPanel)
Dim ribToolTip As RibbonToolTip = New RibbonToolTip
ribToolTip.Command = "My Command"
ribToolTip.Title = "My Title"
ribToolTip.Content = "My Content"
ribToolTip.ExpandedContent = "my Expanded Content !"
'enable f1 Help
ribToolTip.IsHelpEnabled = True
Dim ribRow1 As RibbonRowPanel = New RibbonRowPanel
ribRow1.Tag = "Row1"
Dim ribButton As RibbonButton = New RibbonButton
ribButton.Text = "PLINE"
ribButton.ShowText = True
ribButton.CommandParameter = "\Xlb\Xlb_PLINE"
ribButton.CommandHandler = New AdskCommandHandler
ribButton.HelpSource = New System.Uri("C:\Contents\Sample.chm", UriKind.RelativeOrAbsolute)
ribButton.HelpTopic = "Sanmple"
ribButton.IsToolTipEnabled = True
ribButton.ToolTip = ribToolTip
ribSourcePanel.Items.Add(ribButton)
ribTab.IsActive = True
End Sub
End Class
Public Class AdskCommandHandler
'Implements System.Windows.Input.ICommand
Public Function CanExecute(ByVal parameter As Object) As Boolean
Return True
End Function
Public Event CanExecuteChanged As EventHandler
Public Sub Execute(ByVal parameter As Object)
Dim ribBtn As Autodesk.Windows.RibbonButton = TryCast(parameter, Autodesk.Windows.RibbonButton)
If ribBtn.CommandParameter.ToString <> "" Then
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(ribBtn.CommandParameter.ToString, True, False, True)
End If
End Sub
End Class