)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use the configuration file as an embedded resource in WinForms SyntaxEditor (EditControl) application?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: December 12, 2019

Adding configuration file

1. Include the configuration file - DefaultEditorConfig.xml in the project using the VS.NET designer and set its BuildAction property to Embedded Resource in the properties grid.

2. Use the following method to access the config file stream from the resources.

C#

private Stream LoadConfigFromResource(string configFileName)
{
    Assembly assembly;
    Stream configStream = null;
    try
    {
        assembly = Assembly.GetExecutingAssembly();
        configStream = (Stream)assembly.GetManifestResourceStream("SimpleEdit." + configFileName);
    }
    catch(Exception ex)
    {
       Console.WriteLine(ex.ToString());
    }
    return configStream;
}

 

VB

Private Function LoadConfigFromResource(ByVal configFileName As String) As Stream
    Dim assembly As Assembly
    Dim configStream As Stream = Nothing
    Try
        assembly = Assembly.GetExecutingAssembly()
        configStream = CType(assembly.GetManifestResourceStream("SimpleEdit." + configFileName), Stream)
    Catch ex As Exception
        Console.WriteLine(ex.ToString())
    End Try
    Return configStream
End Function

 

3. Apply the config file stream using the following code.

 

C#

Stream configStream = LoadConfigFromResource("DefaultEditorConfig.xml");
this.editControl1.Configurator.Open(configStream);
this.editControl1.ApplyConfiguration("C");

 

VB

Dim configStream As Stream = LoadConfigFromResource("DefaultEditorConfig.xml")
Me.editControl1.Configurator.Open(configStream)
Me.editControl1.ApplyConfiguration("C")

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon