[]
In order to associate topics from your Help file with form controls, you must specify the source Help file.
You can do this from the C1DynamicHelp Tasks menu by setting the HelpSource property to any *.chm file or NetHelp *.htm file (use the default.htm or the file name that was used as the base URL for the NetHelp target.). In this example, we will use the C1Sample.chm installed with DynamicHelp for WinForms, by default.
Once a source Help file is specified, you can prepare the C1DynamicHelp control to be used in authoring mode. This step should be performed by the developer.
Click the C1DynamicHelp smart tag (
) to open the Tasks menu.
Click the ellipsis button next to the HelpSource property.
Locate and select the C1Sample.chm. It is located in the Tutorials/Data folder, by default.
Prepare the C1DynamicHelp control for using in authoring mode:
1. From the Properties window, set the Form1.KeyPreview property to True.
2. Override the OnKeyDown method by adding the following code:
To write code in Visual Basic
' toggle authoring mode when the user hits Ctrl+Shift+A
Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
If (e.KeyCode = Keys.A And e.Control And e.Shift) Then
C1DynamicHelp1.AuthoringMode = Not C1DynamicHelp1.AuthoringMode
End If
MyBase.OnKeyDown(e)
End SubTo write code in C#
// toggle authoring mode when the user hits Ctrl+Shift+A
override protected void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.A && e.Control && e.Shift)
{
c1DynamicHelp1.AuthoringMode = !c1DynamicHelp1.AuthoringMode;
}
base.OnKeyDown(e);
}3. Create a handler for the Form_Load event and insert the following code to instruct the C1DynamicHelp control to subscribe the controls to the events for showing topics:
To write code in Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
C1DynamicHelp1.TopicMap.Refresh()
End SubTo write code in C#
private void Form1_Load(object sender, EventArgs e)
{
c1DynamicHelp1.TopicMap.Refresh();
}Create a handler for the Form_Closing event and insert the following code to ask the user whether to save changes made in the topic map:
To write code in Visual Basic
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If (C1DynamicHelp1.TopicMap.HasChanges) Then
Dim dr As DialogResult
dr = MessageBox.Show("Would you like to save the changes you made to control/topic map?", "C1DynamicHelp Tutorial", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If (dr = DialogResult.Yes) Then
C1DynamicHelp1.TopicMap.Save()
ElseIf (dr = DialogResult.Cancel) Then
e.Cancel = True
End If
End If
End SubTo write code in C#
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (c1DynamicHelp1.TopicMap.HasChanges)
{
DialogResult result = MessageBox.Show("Would you like to save the changes you made to control/topic map?", "C1DynamicHelp Tutorial", MessageBoxButtons.YesNoCancel , MessageBoxIcon.Question);
if (result == DialogResult.Yes)
c1DynamicHelp1.TopicMap.Save();
else if (result == DialogResult.Cancel)
e.Cancel = true;
}
}No controls have topics associated with them yet. The application can now be used by a Help author to map topics to controls.