New to Telerik UI for WinForms? Download free 30-day trial

Save/Load Layout

RadDataLayout allows changes at runtime. The control can export/import its layout which is stored in Xml format. This funtionality can be utilized by calling the SaveLayout and LoadLayout methods.

Save the layout.

private void SaveLayout()
{
    using (SaveFileDialog sfd = new SaveFileDialog())
    {
        sfd.DefaultExt = ".xml";
        sfd.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
        if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            this.radDataLayout1.LayoutControl.SaveLayout(sfd.FileName);
        }
    }
}

Private Sub SaveLayout()
    Using sfd As New SaveFileDialog()
        sfd.DefaultExt = ".xml"
        sfd.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"
        If sfd.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Me.RadDataLayout1.LayoutControl.SaveLayout(sfd.FileName)
        End If
    End Using
End Sub

Load the Layout

private void LoadLayout()
{
    using (OpenFileDialog ofd = new OpenFileDialog())
    {
        ofd.DefaultExt = ".xml";
        ofd.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
        if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            this.radDataLayout1.LayoutControl.LoadLayout(ofd.FileName);
        }
    }
}

Private Sub LoadLayout()
    Using ofd As New OpenFileDialog()
        ofd.DefaultExt = ".xml"
        ofd.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"
        If ofd.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Me.RadDataLayout1.LayoutControl.LoadLayout(ofd.FileName)
        End If
    End Using
End Sub

The layout can be saved/loaded with the customize dialog as well.

See Also

In this article