Provides methods for showing Help topics and adding and removing Help keywords at design time.
For a list of all members of this type, see IHelpService Members.
[Visual Basic] Public Interface IHelpService [C#] public interface IHelpService [C++] public __gc __interface IHelpService [JScript] public interface IHelpService
The design-time environment provides a Help system that attempts to locate relevant Help topics to display when a user presses F1. The Help system maintains a set of current context keywords that are used to identify relevant topics if Help is requested. By default, keywords are associated with selected class objects and properties of objects in the design time environment. The default keyword for a component or property is its fully qualified class or property name. Specific keywords are also associated with certain modes, such as when multiple objects are selected. If a custom Help collection is integrated with the design-time environment by configuring it for an external help provider, a documentation provider can associate a topic for a specific component class or property with a keyword consisting of the item's fully qualified type or member name.
The IHelpService can be used to invoke the help service with a specified keyword using the ShowHelpFromKeyword method, or to invoke a help topic from a specified URL using the ShowHelpFromUrl method.
The IHelpService can also be used to add or remove Help keywords at design time. Selecting a component or property at design time sets a default context keyword consisting of the fully qualified type or member name of the selection, and removes the keywords for any previously selected and no longer selected components or properties.
Because the Help system does not automatically remove custom Help keywords, you must explicitly remove a custom keyword when it no longer applies. You can monitor the events defined by the ISelectionService interface to determine when a component selection changes. Based on those events, you can add a Help context attribute for a component when it is selected and then remove the Help context attribute when the selection no longer includes the component.
[Visual Basic, C#] The following example demonstrates a designer that uses the IHelpService to add and remove Help context attributes for the included control. To use this sample, compile it to a class library and add an instance of the control to a Form. In designer view, selecting the component and pressing F1 attempts to look up relevant Help topics based on the current Help context keyword or keywords. Right-click the component and the shortcut menu displays commands, including two custom DesignerVerb commands named Add IHelpService Help Keyword and Remove IHelpService Help Keyword. These commands can be used to add or remove a Help context keyword of the value "IHelpService", which attempts to raise the IHelpService topic when F1 is pressed.
[Visual Basic] Imports System Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing Imports System.IO Imports System.Windows.Forms Imports System.Windows.Forms.Design Namespace IHelpServiceSample Public Class HelpDesigner Inherits System.Windows.Forms.Design.ControlDesigner Public Sub New() End Sub 'New Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Get Return New DesignerVerbCollection(New DesignerVerb() {New DesignerVerb("Add IHelpService Help Keyword", AddressOf Me.addKeyword), New DesignerVerb("Remove IHelpService Help Keyword", AddressOf Me.removeKeyword)}) End Get End Property Private Sub addKeyword(ByVal sender As Object, ByVal e As EventArgs) Dim hs As IHelpService = CType(Me.Control.Site.GetService(GetType(IHelpService)), IHelpService) hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword) End Sub 'addKeyword Private Sub removeKeyword(ByVal sender As Object, ByVal e As EventArgs) Dim hs As IHelpService = CType(Me.Control.Site.GetService(GetType(IHelpService)), IHelpService) hs.RemoveContextAttribute("keyword", "IHelpService") End Sub 'removeKeyword End Class 'HelpDesigner <Designer(GetType(HelpDesigner))> _ Public Class HelpTestControl Inherits System.Windows.Forms.UserControl Public Sub New() Me.Size = New Size(320, 100) Me.BackColor = Color.White End Sub 'New Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim brush = New SolidBrush(Color.Blue) e.Graphics.DrawString("IHelpService Example Designer Control", New Font(FontFamily.GenericMonospace, 10), brush, 5, 5) e.Graphics.DrawString("Right-click this component for", New Font(FontFamily.GenericMonospace, 8), brush, 5, 25) e.Graphics.DrawString("add/remove Help context keyword commands.", New Font(FontFamily.GenericMonospace, 8), brush, 5, 35) e.Graphics.DrawString("Press F1 while this component is", New Font(FontFamily.GenericMonospace, 8), brush, 5, 55) e.Graphics.DrawString("selected to raise Help topics for", New Font(FontFamily.GenericMonospace, 8), brush, 5, 65) e.Graphics.DrawString("the current keyword or keywords", New Font(FontFamily.GenericMonospace, 8), brush, 5, 75) End Sub 'OnPaint End Class 'HelpTestControl End Namespace 'IHelpServiceSample [C#] using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.IO; using System.Windows.Forms; using System.Windows.Forms.Design; namespace IHelpServiceSample { public class HelpDesigner : System.Windows.Forms.Design.ControlDesigner { public HelpDesigner() { } public override System.ComponentModel.Design.DesignerVerbCollection Verbs { get { return new DesignerVerbCollection( new DesignerVerb[] { new DesignerVerb("Add IHelpService Help Keyword", new EventHandler(this.addKeyword)), new DesignerVerb("Remove IHelpService Help Keyword", new EventHandler(this.removeKeyword)) } ); } } private void addKeyword(object sender, EventArgs e) { IHelpService hs = (IHelpService) this.Control.Site.GetService(typeof(IHelpService)); hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword) } private void removeKeyword(object sender, EventArgs e) { IHelpService hs = (IHelpService) this.Control.Site.GetService(typeof(IHelpService)); hs.RemoveContextAttribute("keyword", "IHelpService"); } } [Designer(typeof(HelpDesigner))] public class HelpTestControl : System.Windows.Forms.UserControl { public HelpTestControl() { this.Size = new Size(320, 100); this.BackColor = Color.White; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Brush brush = new SolidBrush(Color.Blue); e.Graphics.DrawString("IHelpService Example Designer Control", new Font( FontFamily.GenericMonospace, 10 ), brush, 5, 5); e.Graphics.DrawString("Right-click this component for", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 25); e.Graphics.DrawString("add/remove Help context keyword commands.", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 35); e.Graphics.DrawString("Press F1 while this component is", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 55); e.Graphics.DrawString("selected to raise Help topics for", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 65); e.Graphics.DrawString("the current keyword or keywords", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 75); } } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System.ComponentModel.Design
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
IHelpService Members | System.ComponentModel.Design Namespace | HelpKeywordType | HelpContextType