# Loading TileControl From an XML File

## Content



This task shows how to load the C1TileControl as an XML File at run time and in code.

### Load C1TileControl as an XML file at run time

To load the C1TileControl as an XML file at run time, complete the following:

1.  Right-click the C1TileControl and select **Load From XML File** item from the context menu.<br />![](https://cdn.mescius.io/document-site-files/images/9533f9b7-015c-42ba-9666-c32678ceddaf/imagesext/image9_9.png)
    
    The **Load From Xml File** dialog box appears.
    
2.  Browse to the location you wish to load the xml file.
3.  Click Open in the **Load From Xml File** dialog box.

### Load C1TileControl from XML file in code

To load template1 as an XML file in code, complete the following:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
Private Sub btnLoadXml_Click(sender As Object, e As EventArgs)
       Using dlg As New OpenFileDialog()
              dlg.DefaultExt = ".xml"
              dlg.Filter = "XML files|*.xml|All files|*.*"
              dlg.Title = "Load From Xml File"
              If dlg.ShowDialog() = DialogResult.OK Then
                     Try
                           template1.LoadXml(dlg.FileName)
                     Catch
                           MessageBox.Show("Bad tilecontrol XML.", dlg.Title)
                     End Try
              End If
       End Using
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 btnLoadXml_Click(object sender, EventArgs e)
{
    using (OpenFileDialog dlg = new OpenFileDialog())
    {
        dlg.DefaultExt = ".xml";
        dlg.Filter = "XML files|*.xml|All files|*.*";
        dlg.Title = "Load From Xml File";
        if (dlg.ShowDialog() == DialogResult.OK)
        {
            try
            {
                Tilecontrol.LoadXml(dlg.FileName);
            }
            catch
            {
                MessageBox.Show("Bad tilecontrol XML.", dlg.Title);
            }
        }
    }
}
```

DOC-DETAILS-TAG-CLOSE