Save datagridview layout to file

Hi,

I want to save a datagridview layout to a file. Not the data - just the columns, their formatting and the fields they are bound to. Can this be done (and how!)

Paul.


Answer this question

Save datagridview layout to file

  • Murali Krishna K

    How could IPersistComponentSettings be implemented  Does anyone has some sample code for implementing 'LoadComponentSettings', 'SaveComponentSettings',..

    thanks
    Robert

  • deviaaraprasad

  • Vince Scaccia

    public void LoadComponentSettings()
    {
    mEngineSettings.Reload();
    }

    public void ResetComponentSettings()
    {
    mEngineSettings.Reset();
    }

    public void SaveComponentSettings()
    {
    mEngineSettings.Save();
    }

    Where mEngineSettings is an instance of:

    public class EngineSettings: ApplicationSettingsBase
    {

    [UserScopedSetting]
    public String TestString
    {

    get { return (String )this["TestString"]; }
    set { this["TestString"] = value; }

    }

    }


  • JLL05

    Hello

    How to use this to define userControl properties. the usercontrol is contained in another assembly than main application and the properties values have to be registered in a settings file with the main assembly

    Thanks in advance

    Pier


  • MSGALE

    Thanks for your reply

    I already read this article, and more regarding IPersistComponentSettings interface

    but I did not success to use it....

    Do you know where I can find a simple sample

    Thanks Pier


  • Scriptfox

    I don't know if this is what you're asking for, but this article helped me: http://msdn2.microsoft.com/en-US/library/system.configuration.applicationsettingsbase(VS.80).aspx

    It's not for a UserControl, but it should be similar - apply the example code for a UserControl instead of a WinForm, and make call the Save() and Reload() methods for the IPersistComponentSettings-methods.


  • Sushanth

    One way to do this would be to inherit from DataGridView and implement IPersistComponentSettings. This is a new interface in Whidbey exactly for this use - to persist settings. You can then create you own Settings class (which inherits from ApplicationSettingsBase) and define all properties that you would like to persist. You can also choose what is the scope of persistance - User level, application level, etc.

    HTH,
    -Dinesh Chandnani

  • Save datagridview layout to file