控制布局保存/加载 [英] Controls layout save/load

查看:58
本文介绍了控制布局保存/加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有没有办法将控件的布局(位置,大小,可见性,

外观等)保存到文件中(xml ?)并且还能够从

文件加载布局?这个想法是这些文件扫描作为可能有不同偏好的不同

客户的模板。


有人使用过这个并且可以发布一些代码那么

将受到高度赞赏。


谢谢


问候

Hi

Is there a way to save the layout of controls (position, size, visibility,
appearance etc.) to a file (xml?) and also be able to load the layout from a
file? The idea being that these file scan serve as templates for different
clients who may have different preferences.

Is someone has worked with this and can post some code examples then that
would be highly appreciated.

Thanks

Regards

推荐答案



http://windowsforms.net/articles/wfml.aspx


Ken

--------- -----

" John" <乔** @ nospam.infovis.co.uk>在留言中写道

新闻:哦************** @ tk2msftngp13.phx.gbl ...




有没有办法将控件的布局(位置,大小,可见性,

外观等)保存到文件(xml?)并且还能够加载

文件的布局?这个想法是这些文件扫描作为可能有不同偏好的不同

客户的模板。


有人使用过这个并且可以发布一些代码那么

将受到高度赞赏。


谢谢


问候

Hi,

http://windowsforms.net/articles/wfml.aspx

Ken
--------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...
Hi

Is there a way to save the layout of controls (position, size, visibility,
appearance etc.) to a file (xml?) and also be able to load the layout from a
file? The idea being that these file scan serve as templates for different
clients who may have different preferences.

Is someone has worked with this and can post some code examples then that
would be highly appreciated.

Thanks

Regards


John,


当我看到你的问题时我得到了这个想法,(当你需要来自

的设置时)在形式方面,你需要稍微改变它,但是在我看来,这显示了这个想法非常好。它甚至可以对表格进行所有控制。

放置在一个控件中的控件。


经过测试和工作。


\\\需要一个带有一些控件的表单一个按钮开始动作。

私有ds作为新数据集

私有子按钮1_Click(ByVal发送者为System.Object,_

ByVal e As System.EventArgs)处理Button1.Click

Dim dt As新的DataTable

ds.Tables.Add(dt)

dt.Columns.Add(" Type")

dt.Columns.Add (名称)

dt.Columns.Add(" Height")

dt.Columns.Add(" Width")

dowrite(Me)

ds.WriteXml(" c:\ test1 \ MyyControlSettings.xml")

End Sub

Private Sub dowrite(ByVal parentCtr As Control)

Dim ctr As Control

For each ctr in parentCtr.Controls

Dim dr As DataRow = ds .Tables(0).NewRow

dr(" Type")= ctr.GetType.ToString

dr(" Name")= ctr.Name

dr(Height)= ctr.Height

dr(Width)= ctr.Width

ds.Tables(0)。 Rows.Add(dr)

dowrite(ctr)

下一页

End Sub

///


我希望这会有所帮助,


Cor
John,

When I saw your question I got this idea, (when you need the settings from
the form as well, you need to change it a little bit, however this shows
the idea in my opinion very well. It does all controls on a form even the
controls placed in a control.

It is tested and works.

\\\Needs just a form with some controls and one button to start the action.
Private ds As New DataSet
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("Type")
dt.Columns.Add("Name")
dt.Columns.Add("Height")
dt.Columns.Add("Width")
dowrite(Me)
ds.WriteXml("c:\test1\MyControlSettings.xml")
End Sub
Private Sub dowrite(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
Dim dr As DataRow = ds.Tables(0).NewRow
dr("Type") = ctr.GetType.ToString
dr("Name") = ctr.Name
dr("Height") = ctr.Height
dr("Width") = ctr.Width
ds.Tables(0).Rows.Add(dr)
dowrite(ctr)
Next
End Sub
///

I hope this helps,

Cor


哇!!我拿它装文件很简单吗?


谢谢


问候


" Cor Ligthert <无************ @ planet.nl>在消息中写道

news:e6 ************** @ TK2MSFTNGP12.phx.gbl ...
Wow!! I take it loading the file is as easy?

Thanks

Regards

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP12.phx.gbl...
John,
当我看到你的问题时我得到了这个想法,(当你需要来自
表格的设置时,你需要稍微改变它,但是这显示了这个想法我的意见非常好。它可以对表格上的所有控件进行控制。

它经过测试和运作。

\\ \只需要一个带有一些控件的表单和一个按钮来启动
操作。
Private ds作为新数据集
Private Sub Button1_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs)处理Button1.Click
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add(" Type")
dt.Columns.Add(" Name")
dt.Columns.Add(" Height")
dt.Columns.Add(" Width")
dowrite(Me)
ds.Writ eXml(" c:\ test1 \ MyControlSettings.xml")
End Sub
Private Sub dowrite(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr在parentCtr.Controls中
Dim dr As DataRow = ds.Tables(0).NewRow
dr(" Type")= ctr.GetType.ToString
dr(" Name")= ctr.Name
dr(" Height")= ctr.Height
dr(" Width")= ctr.Width
ds.Tables(0).Rows.Add(dr)
dowrite(ctr)
下一页
// @

我希望这会有所帮助,

Cor
John,

When I saw your question I got this idea, (when you need the settings from
the form as well, you need to change it a little bit, however this shows
the idea in my opinion very well. It does all controls on a form even the
controls placed in a control.

It is tested and works.

\\\Needs just a form with some controls and one button to start the
action.
Private ds As New DataSet
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("Type")
dt.Columns.Add("Name")
dt.Columns.Add("Height")
dt.Columns.Add("Width")
dowrite(Me)
ds.WriteXml("c:\test1\MyControlSettings.xml")
End Sub
Private Sub dowrite(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
Dim dr As DataRow = ds.Tables(0).NewRow
dr("Type") = ctr.GetType.ToString
dr("Name") = ctr.Name
dr("Height") = ctr.Height
dr("Width") = ctr.Width
ds.Tables(0).Rows.Add(dr)
dowrite(ctr)
Next
End Sub
///

I hope this helps,

Cor



这篇关于控制布局保存/加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆