How to easily save configuration information such as the position and size of the WinForm control, winform Control
Because of the different resolutions, screen themes, and font sizes, the display effects of forms vary with machines. The elastic design of forms does not meet various requirements. To ensure satisfactory results in various situations. The various display modes of the form can be changed, and it is very important to save and load the configuration. I tried to write a class under C # To Do This. The purpose is to make it easy to use, as small as possible, load fast, and scalable.
First use:
This class is applicable to the most common requirements, such as the form position and size. And the column width of the table. Design. You can expand it as needed.
Load the configuration information as follows:
private void FrmMain_Load(object sender, EventArgs e){ SetupColumns(); oConfig.Load_Columns_Width(dgv1, "huodan_frmlisthuo_dgv1"); oConfig.SetSaveFlag("huodan_frmlisthuo_dgv1", false); oConfig.Load_Form_Size(this, "huodan_frmlisthuo_frm"); oConfig.SetSaveFlag("huodan_frmlisthuo_frm", false);}
Save it before closing the form:
private void FrmListHuo_FormClosing(object sender, FormClosingEventArgs e){ oConfig.Save_Columns_Width(dgv1, "huodan_frmlisthuo_dgv1"); oConfig.Save_Form_Size(this, "huodan_frmlisthuo_frm"); }
Not every time the form is closed, it is saved. If necessary, set the Save request:
private void dgv1_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e){ oConfig.SetSaveFlag("huodan_frmlisthuo_dgv1",true);}private void FrmListHuo_ResizeEnd(object sender, EventArgs e){ oConfig.SetSaveFlag("huodan_frmlisthuo_frm", true);}
Class content can be downloaded to the blog space (http://www.pudn.com/downloads768/sourcecode/windows/csharp/detail3046853.html), don't speak more, understand Don't speak, don't understand is tired.