Export (0) Print
Expand All

Help Class

Encapsulates the HTML Help 1.0 engine.


Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public ref class Help

The Help type exposes the following members.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberShowHelp(Control, String)Displays the contents of the Help file at the specified URL.
Public methodStatic memberShowHelp(Control, String, String)Displays the contents of the Help file found at the specified URL for a specific keyword.
Public methodStatic memberShowHelp(Control, String, HelpNavigator)Displays the contents of the Help file found at the specified URL for a specific topic.
Public methodStatic memberShowHelp(Control, String, HelpNavigator, Object)Displays the contents of the Help file located at the URL supplied by the user.
Public methodStatic memberShowHelpIndexDisplays the index of the specified Help file.
Public methodStatic memberShowPopupDisplays a Help pop-up window.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

You cannot create a new instance of the Help class. To provide Help for an application, call the static ShowHelp and ShowHelpIndex methods.

You can use Help to show compiled Help files (.chm) or HTML files in the HTML Help format. Compiled Help files provide a table of contents, an index, search capability, and keyword links in pages. Shortcuts work only in compiled Help files.

You can generate HTML Help 1.x files by using HTML Help Workshop. For more information about HTML Help, see "HTML Help Workshop" and other HTML Help topics at Microsoft HTML Help.

The following code example displays a form that contains three buttons that can be used to interact with the Mspaint.chm Help file. The Show Help Index button displays the Index tab for the Help file. The Show Help button displays content in the Help file based on the value that is selected in the Help Navigator list. The Show Keyword button displays content in the Help file based on the keyword that is specified in the Keyword text box.

For example, to show the Ovals Help page by the index value, select the HelpNavigator::KeywordIndex value in the Help Navigator drop-down list, type ovals in the Parameter text box, and then click the Show Help button. To show the "To paint with a brush" Help topic by the keyword, type mspaint.chm::/paint_brush.htm in the Keyword text box, and then click the Show Keyword button.

The example uses the ShowHelp method to display the different Help tabs and Help topics, and the ShowHelpIndex method to display the Help index.

#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
public ref class Form1: public System::Windows::Forms::Form
   String^ helpfile;
   System::Windows::Forms::Button^ showIndex;
   System::Windows::Forms::Button^ showHelp;
   System::Windows::Forms::Label ^ label1;
   System::Windows::Forms::ComboBox^ navigatorCombo;
   System::Windows::Forms::Button^ showKeyword;
   System::Windows::Forms::TextBox^ keyword;
   System::Windows::Forms::Label ^ label2;
   System::Windows::Forms::Label ^ label3;
   System::Windows::Forms::TextBox^ parameterTextBox;

      helpfile = "mspaint.chm";
      this->showIndex = gcnew System::Windows::Forms::Button;
      this->showHelp = gcnew System::Windows::Forms::Button;
      this->navigatorCombo = gcnew System::Windows::Forms::ComboBox;
      this->label1 = gcnew System::Windows::Forms::Label;
      this->showKeyword = gcnew System::Windows::Forms::Button;
      this->keyword = gcnew System::Windows::Forms::TextBox;
      this->label2 = gcnew System::Windows::Forms::Label;
      this->label3 = gcnew System::Windows::Forms::Label;
      this->parameterTextBox = gcnew System::Windows::Forms::TextBox;

      // Help Navigator Label 
      this->label1->Location = System::Drawing::Point( 112, 64 );
      this->label1->Size = System::Drawing::Size( 168, 16 );
      this->label1->Text = "Help Navigator:";

      // Keyword Label  
      this->label2->Location = System::Drawing::Point( 120, 184 );
      this->label2->Size = System::Drawing::Size( 100, 16 );
      this->label2->Text = "Keyword:";

      // Parameter Label 
      this->label3->Location = System::Drawing::Point( 112, 120 );
      this->label3->Size = System::Drawing::Size( 168, 16 );
      this->label3->Text = "Parameter:";

      // Show Index Button 
      this->showIndex->Location = System::Drawing::Point( 16, 16 );
      this->showIndex->Size = System::Drawing::Size( 264, 32 );
      this->showIndex->TabIndex = 0;
      this->showIndex->Text = "Show Help Index";
      this->showIndex->Click += gcnew System::EventHandler( this, &Form1::showIndex_Click );

      // Show Help Button 
      this->showHelp->Location = System::Drawing::Point( 16, 80 );
      this->showHelp->Size = System::Drawing::Size( 80, 80 );
      this->showHelp->TabIndex = 1;
      this->showHelp->Text = "Show Help";
      this->showHelp->Click += gcnew System::EventHandler( this, &Form1::showHelp_Click );

      // Show Keyword Button 
      this->showKeyword->Location = System::Drawing::Point( 16, 192 );
      this->showKeyword->Size = System::Drawing::Size( 88, 32 );
      this->showKeyword->TabIndex = 4;
      this->showKeyword->Text = "Show Keyword";
      this->showKeyword->Click += gcnew System::EventHandler( this, &Form1::showKeyword_Click );

      // Help Navigator ComboBox 
      this->navigatorCombo->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
      this->navigatorCombo->Location = System::Drawing::Point( 112, 80 );
      this->navigatorCombo->Size = System::Drawing::Size( 168, 21 );
      this->navigatorCombo->TabIndex = 2;

      // Keyword TextBox 
      this->keyword->Location = System::Drawing::Point( 120, 200 );
      this->keyword->Size = System::Drawing::Size( 160, 20 );
      this->keyword->TabIndex = 5;
      this->keyword->Text = "";

      // Parameter TextBox 
      this->parameterTextBox->Location = System::Drawing::Point( 112, 136 );
      this->parameterTextBox->Size = System::Drawing::Size( 168, 20 );
      this->parameterTextBox->TabIndex = 8;
      this->parameterTextBox->Text = "";

      // Set up how the form should be displayed and add the controls to the form. 
      this->ClientSize = System::Drawing::Size( 292, 266 );
      array<System::Windows::Forms::Control^>^formControls = {this->parameterTextBox,this->label3,this->label2,this->keyword,this->showKeyword,this->label1,this->navigatorCombo,this->showHelp,this->showIndex};
      this->Controls->AddRange( formControls );
      this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
      this->Text = "Help App";

      // Load the various values of the HelpNavigator enumeration 
      // into the combo box.
      TypeConverter^ converter;
      converter = TypeDescriptor::GetConverter( HelpNavigator::typeid );
      System::Collections::IEnumerator^ myEnum = converter->GetStandardValues()->GetEnumerator();
      while ( myEnum->MoveNext() )
         Object^ value = safe_cast<Object^>(myEnum->Current);
         navigatorCombo->Items->Add( value );

   void showIndex_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )

      // Display the index for the help file.
      Help::ShowHelpIndex( this, helpfile );

   void showHelp_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )

      // Display Help using the Help navigator enumeration 
      // that is selected in the combo box. Some enumeration 
      // values make use of an extra parameter, which can 
      // be passed in through the Parameter text box.
      HelpNavigator navigator = HelpNavigator::TableOfContents;
      if ( navigatorCombo->SelectedItem != nullptr )
         navigator =  *safe_cast<HelpNavigator^>(navigatorCombo->SelectedItem);

      Help::ShowHelp( this, helpfile, navigator, parameterTextBox->Text );

   void showKeyword_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )

      // Display help using the provided keyword.
      Help::ShowHelp( this, helpfile, keyword->Text );

int main()
   Application::Run( gcnew Form1 );

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2014 Microsoft