New to Telerik UI for WinFormsStart a free 30-day trial

Save and Load Layout

Updated over 6 months ago

Save/Load layout functionality gives your applications the opportunity to preserve the custom defined keyboard layout. Those layout settings are written in a XML file.

Before proceeding further, it is recommended to get yourself familiar with the Default Layouts and Logical Keyboard Layout articles which demonstrates how you can access the different keyboard layout panels and add custom keys to achieve the desired custom layout which can be preserved later to a XML file.

Here is a sample demonstrating how you can implement a Save Layout button event handler:

Save custom defined layout

C#
string s = "default.xml";
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
dialog.Title = "Select a xml file";
if (dialog.ShowDialog() == DialogResult.OK)
{
    s = dialog.FileName;
}
this.radVirtualKeyboard1.SaveLayout(s);

The code snippets below demonstrates how you can implement a Load Layout button event handler:

Load custom defined layout

C#

string s = "default.xml";
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
dialog.Title = "Select a xml file";
if (dialog.ShowDialog() == DialogResult.OK)
{
    s = dialog.FileName;
}
this.radVirtualKeyboard1.LoadLayout(s);

RadVirtualKeyboard provides three overloads for the SaveLayout and LoadLayout methods:

MethodDescription
SaveLayout(XmlWriter xmlWriter)Stores RadVirtualKeyboard's layout state in XML format to a XmlWriter, using the serialization information provided by the XmlSerializationInfo property.
SaveLayout(Stream stream)Stores RadVirtualKeyboard's layout state in XML format to a stream, using the serialization information provided by the XmlSerializationInfo property.
SaveLayout(string fileName)Stores RadVirtualKeyboard's layout state in XML format to a file, using the serialization information provided by the XmlSerializationInfo property.
LoadLayout(string fileName)Loads RadVirtualKeyboard's layout state from a XML file, using the serialization information provided by the XmlSerializationInfo property.
LoadLayout(Stream stream)Loads RadVirtualKeyboard's layout state from a stream, using the serialization information provided by theXmlSerializationInfo property.
LoadLayout(XmlReader xmlReader)Loads RadVirtualKeyboard's layout state from a XmlReader, using the serialization information provided by the XmlSerializationInfo property.

In our Demo application >> Virtual Keyboard >> Settings example you can find two XML files for custom keyboard layouts: Dvorak Layout and Colemak Layout.

Not finding the help you need?
Contact Support