How to auto save and auto load all properties in winforms C#?

后端 未结 4 655
面向向阳花
面向向阳花 2020-12-17 06:12

How to auto save all properties winforms when closed and auto load all properties winforms when load ? C#

using System;
using System.Collections.Generic;
us         


        
4条回答
  •  自闭症患者
    2020-12-17 06:31

    I'm not aware of any automatic method built into the Form base class, but adding it yourself isn't hard.

    You could tap the window load and close events to cache off all relevant properties to a backing store and then reload them later.

    Register an event handler to the Form.Load and Form.Closing event handlers. When Form.Closing occurs, save the forms state to a file or database. When Form.Load occurs, check to see if a saved state is present and if so, reload the from from the saved state.

提交回复
热议问题