# Step 2 of 4: Binding C1Editor to a Document

Learn how to bind C1Editor control to a document that can either be saved or loaded in any application.

## Content



Now you can bind [C1Editor](/componentone/api/win/online-richtexteditor/dotnet-framework-api/C1.Win.C1Editor.4.8/C1.Win.C1Editor.C1Editor.html) to a document that can be saved to a file and loaded later when needed. If this document is edited within the C1Editor, the underlying XmlDocument syncs to match it.

1.  Click the **View** menu and select **Code** to switch to code view.
2.  Add the following Imports (Visual Basic) or using (C#) statements to your project so you can use abbreviated names.
    
    DOC-DETAILS-TAG-OPEN
    
    DOC-SUMMARY-TAG-OPEN
    
    To write code in Visual Basic
    
    DOC-SUMMARY-TAG-CLOSE
    
    ```vbnet
    Imports System.Xml
    Imports C1.Win.C1Editor
    ```
    
    DOC-DETAILS-TAG-CLOSE
    
    DOC-DETAILS-TAG-OPEN
    
    DOC-SUMMARY-TAG-OPEN
    
    To write code in C#
    
    DOC-SUMMARY-TAG-CLOSE
    
    ```csharp
    using System.Xml;
    using C1.Win.C1Editor;
    ```
    
    DOC-DETAILS-TAG-CLOSE
    
3.  Create a **Form\_Load** event and add the following code there to create a new document and bind it to C1Editor:
    
    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 Object, ByVal e As EventArgs)
        Dim myDoc As New XmlDocument()
        C1Editor1.Document = myDoc
    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)
    {
      XmlDocument myDoc = new XmlDocument(); 
      c1Editor1.Document = myDoc;
    }
    ```
    
    DOC-DETAILS-TAG-CLOSE
    

In the next step you will add code to apply a cascading style sheet to the C1Editor content.