更新时间:2023-02-16 14:32:33
的你的问题是有点不清楚,但的
如果您需要保存/在加载窗体布局看看
如果您需要保存/加载对象/类看看
编辑:
这将告诉您如何为表单属性仍然存在一定的设置。
的保存并恢复使用XML 一个.NET形式的Setings
也有看的应用程序自动化层 - 使用XML动态生成GUI元素 - 窗体和控件
所有这些都将引导你,你需要去的方向。
我觉得这里的主要目的是
How to auto save all properties winforms when closed and auto load all properties winforms when load ? C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace SControl
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < Controls.Count; i++)
{
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(Controls[i]));
Stream stream = File.Open("test.xml", FileMode.Create);
x.Serialize(stream, Controls[i]);
}
}
}
}
Your question is a little unclear, but
If you require saving/loading of the Form Layout have a look at
Windows Forms User Settings in C#
If you require saving/loading an object/class have a look at
Load and save objects to XML using serialization
EDIT:
This will show you how to persist certain settings for form properties.
Save and Restore Setings of a .NET Form using XML
Also have a look at The Application Automation Layer - Using XML To Dynamically Generate GUI Elements--Forms And Controls
All these will guide you in the direction you need to go.
I think the main objective here is