2

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?
help-info.de
  • 6,695
  • 16
  • 39
  • 41
HariPriya
  • 117
  • 1
  • 2
  • 16

1 Answers1

4

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

help-info.de
  • 6,695
  • 16
  • 39
  • 41
  • Thanks a lot @help-info.de.Now another question raised to me do we need to include topic ID with our title of the context.I have created topic ID manually by creating alias name for my file and then specifying topic ID for that alias name in my .hhp file and I am trying to access it in my properties window.Am I going in the right path or do we have some better solution for this ? – HariPriya Oct 07 '17 at 05:42
  • Yes you need a mapping. Please have a look at [Creating Context-Sensitive Help for Applications](http://www.help-info.de/en/Help_Info_HTMLHelp/hh_context-id.htm#linkstocontext) for further information. As you can the sample is matching the screenshots above. Ask a **new** question for further problems and please search on StackOverflow before asking. – help-info.de Oct 07 '17 at 07:26
  • Please note - it may be better to use a alias.h and a map.h file and put these file name as a link into your *.hhp project file. – help-info.de Oct 07 '17 at 07:31
  • Thanks a lot and lot help-info.de your solutions helped me a lot to achieve what i wanted – HariPriya Oct 09 '17 at 05:04
  • @HariPriya: My pleasure! – help-info.de Oct 09 '17 at 05:08