Where to specify topic id in c# windows application

1.5k Views Asked by At

I am new to C# windows application.I would like to add custom help file using help provider from the toolbar in Microsoft visual studio 2010 for windows application.

I can add my help file and that is working fine. I'd like to context-sensitive help and that is working fine with Help.ShowHelp(). In the properties window we have a HelpNavigator property where it has options like .Topic, .TopicId, .AssociateIndex, .TableOfContents, .Index, .Find. I have chosen .TopicId but i am wondering where to specify my topic ID. I have two questions

  • Is that possible ony by writing code in .cs file of the application?
  • If yes,then what is the purpose of help navigator property?
1

There are 1 best solutions below

5
On BEST ANSWER

Short story - no, you can achieve this (F1-Help) without writing code (but sometimes coding is a better solution).

The HelpNavigator property is an enumeration that specifies the Help command to use when retrieving Help from the Help file for the specified control (see also: Help for controls with VB .NET).

Connecting a CHM help file with your application and providing context-sensitive help for controls has a small learn curve.

Below are (code) examples that demonstrate using context-sensitive help by F1 and how to open the help viewer by TopicId.

F1 - Help

  1. Add a HelpProvider component to the form. This will add properties like .HelpKeyword, .HelpNavigator, .HelpString, .ShowHelp. Set the full path to your CHM file to the HelpProvider.HelpNamespace property.
  2. To enable the help ? button on the form's caption area, set the values of the following form properties HelpButton = True, MaximizeBox = False, MinimizeBox = False.
  3. Use the control properties mentioned above to provide help for a control when it has focus and F1 was pressed or the ? button was clicked by the user. For example, set the button1 HelpKeyword property to 20010 and its HelpNavigator property to .TopicId as shown in the screenshot below.

enter image description here

... and the resulting help viewer window:

enter image description here

Open the Help Viewer

Following code is used to open a Help Viewer and a topic by TopicId 10000:

private void btnTopicId_Click(object sender, EventArgs e)
{
    Help.ShowHelp(this.btnOpenHelpShowTopic, helpProvider1.HelpNamespace, HelpNavigator.TopicId, @"10000");
}

enter image description here