1

I have a project in which I create a blank form and add controls to it from a XML template at runtime. This works well, but it takes a bit of time to do it. I want to know if it is possible to save the layout of the form to a .NET format after it has been defined at runtime so I don't have to keep parsing the xml to create the form. Thanks.

4

2 回答 2

1

您无法序列化windows.forms.control,但下面的链接应该可以帮助您

如何在c#中序列化windows窗体和其他子控件并将它们保存到表中

如何克隆/序列化/复制和粘贴 Windows 窗体控件

顺便说一句,您应该为此查看 WPF。

于 2012-04-24T10:58:23.310 回答
0

Form.Controls是一个Control列表。这些控件中的每一个都包含一个 Width、Height 和 Location 属性,您可以在序列化回 XML 文档时使用这些属性。

基本上我想说的是,你可以序列化 Form.Controls

于 2012-04-24T10:49:58.160 回答