# Step 2 of 4: Set up the C1DynamicHelp control

## Content

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](/componentone/api/win/online-dynamichelp/dotnet-framework-api/C1.Win.C1DynamicHelp.4.8/C1.Win.C1DynamicHelp.C1DynamicHelp.HelpSource.html) 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](/componentone/api/win/online-dynamichelp/dotnet-framework-api/C1.Win.C1DynamicHelp.4.8/C1.Win.C1DynamicHelp.C1DynamicHelp.html) control to be used in **authoring mode**. This step should be performed by the developer.

1. Click the C1DynamicHelp smart tag (![](https://cdn.mescius.io/document-site-files/images/3b487bec-9ad4-47e0-ad8d-39717dc3c4e1/imagesext/image9_1.png)) to open the **Tasks** menu.
2. Click the **ellipsis** button next to the HelpSource property.
3. Locate and select the **C1Sample.chm**. It is located in the Tutorials/Data folder, by default.
4. 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:
    DOC-DETAILS-TAG-OPEN
    DOC-SUMMARY-TAG-OPEN
    To write code in Visual Basic
    DOC-SUMMARY-TAG-CLOSE

    ```vbnet
    ' 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 Sub
    ```

    DOC-DETAILS-TAG-CLOSE
    DOC-DETAILS-TAG-OPEN
    DOC-SUMMARY-TAG-OPEN
    To write code in C#
    DOC-SUMMARY-TAG-CLOSE

    ```csharp
    // 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);
    }
    ```

    DOC-DETAILS-TAG-CLOSE
<br>
    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:
<br>
    DOC-DETAILS-TAG-OPEN
    DOC-SUMMARY-TAG-OPEN
    To write code in Visual Basic
    DOC-SUMMARY-TAG-CLOSE

    ```vbnet
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        C1DynamicHelp1.TopicMap.Refresh()
    End Sub
    ```

    DOC-DETAILS-TAG-CLOSE
    DOC-DETAILS-TAG-OPEN
    DOC-SUMMARY-TAG-OPEN
    To write code in C#
    DOC-SUMMARY-TAG-CLOSE

    ```csharp
    private void Form1_Load(object sender, EventArgs e)
    {
        c1DynamicHelp1.TopicMap.Refresh();
    }
    ```

    DOC-DETAILS-TAG-CLOSE
5. 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:
<br>
    DOC-DETAILS-TAG-OPEN
    DOC-SUMMARY-TAG-OPEN
    To write code in Visual Basic
    DOC-SUMMARY-TAG-CLOSE

    ```vbnet
    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 Sub
    ```

    DOC-DETAILS-TAG-CLOSE
    DOC-DETAILS-TAG-OPEN
    DOC-SUMMARY-TAG-OPEN
    To write code in C#
    DOC-SUMMARY-TAG-CLOSE

    ```csharp
    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;
        }
    }
    ```

    DOC-DETAILS-TAG-CLOSE

No controls have topics associated with them yet. The application can now be used by a Help author to map topics to controls.