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 12 2260
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,
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
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,
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
PS: Is it possible to run something like this as part of ide (macros)? Idea
being this displays all the forms in the project. User selects a name and
form layout is either saved. This is useful when creating templates for
shipping to clients.
Thanks again
Regards
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP12.phx.gbl... 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
Is it possible to save all properties of controls without even knowing what
they are?
Thanks
Regards
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP12.phx.gbl... 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
> Is it possible to save all properties of controls without even knowing what they are?
Have you seen how many properties a control has,
I would not do that, height, width, left, top, color, font and maybe I
forget some is probably more than enough,
Cor
John,
In addition,
You have not have to save more than your program allows the user to change.
Cor
Thanks for that. How can I read the properties back? I guess the problem I
am facing is how to connect the read object's name with the object instance
on the form.
Thank again.
Regards
"Cor Ligthert" <no************@planet.nl> wrote in message
news:OX*************@TK2MSFTNGP09.phx.gbl... Is it possible to save all properties of controls without even knowing what they are? Have you seen how many properties a control has,
I would not do that, height, width, left, top, color, font and maybe I forget some is probably more than enough,
Cor
John,
That should be easy now, however making the sample needed less words.
\\\Add to the same sample this. (and a button of course)
Private Sub Button2_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button2.Click
ds.ReadXml("c:\test1\myformsettings.xml")
ds.Tables(0).DefaultView.Sort = "Name"
DoRead(Me, ds.Tables(0).DefaultView)
End Sub
Public Sub DoRead(ByVal parentCtr As Control, _
ByVal dv As DataView)
Dim ctr As Control
For Each ctr In parentCtr.Controls
Dim i As Integer = dv.Find(ctr.Name)
ctr.Height = CInt(dv(i)("Height"))
ctr.Width = CInt(dv(i)("Width"))
DoRead(ctr, dv)
Next
End Sub
///
I hope this helps,
Cor
Hi,
I wroted Configuration Library with Layout Saver component (it's free, you
can download it with source code) whitch maby is what you are looking for. http://www.habjansoftware.com/download.aspx (Configuration Library with
Layout Saver for .NET). Web page about this library is not yet finished, but
i can guide you thur it if you need (and you also have samples included in
zip).
Basicly what you need to do is to add component to Toolbox (right click on
toolbox->Add remove items->Browse to HS.Configuration.dll and open / import
it. You will see that 'LayoutSaver' component is added to toolbox.
Now you can drag&drop this component on any form you wish to save properties
you require.
When LayoutSaver component is added on form, you can select this form or any
control on it and press F4 to see PropertyGrid and look for property
'LSProperties on LayoutSaver1' and 'LSPropName on LayoutSaver1'..
When you click on 'LSProperties on LayoutSaver1' you will see dropdown
control with ability to select whitch propertyes for specified control you
want to save / restore (see Layout_In_Config_Sample or others).
I hope this helps ..
Regards,
Josip Habjan
URL: http://www.habjansoftware.com
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:uP**************@TK2MSFTNGP14.phx.gbl... Is it possible to save all properties of controls without even knowing what they are?
Thanks
Regards
"Cor Ligthert" <no************@planet.nl> wrote in message news:e6**************@TK2MSFTNGP12.phx.gbl... 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
Thanks for that Josip.
Sees like what I need. Any plans to make it work on vs2005?
Thanks
Regards
"Josip Habjan" <jh*****@spamoff-net.hr> wrote in message
news:d8**********@magcargo.vodatel.hr... Hi,
I wroted Configuration Library with Layout Saver component (it's free, you can download it with source code) whitch maby is what you are looking for. http://www.habjansoftware.com/download.aspx (Configuration Library with Layout Saver for .NET). Web page about this library is not yet finished, but i can guide you thur it if you need (and you also have samples included in zip).
Basicly what you need to do is to add component to Toolbox (right click on toolbox->Add remove items->Browse to HS.Configuration.dll and open / import it. You will see that 'LayoutSaver' component is added to toolbox. Now you can drag&drop this component on any form you wish to save properties you require. When LayoutSaver component is added on form, you can select this form or any control on it and press F4 to see PropertyGrid and look for property 'LSProperties on LayoutSaver1' and 'LSPropName on LayoutSaver1'.. When you click on 'LSProperties on LayoutSaver1' you will see dropdown control with ability to select whitch propertyes for specified control you want to save / restore (see Layout_In_Config_Sample or others).
I hope this helps ..
Regards, Josip Habjan URL: http://www.habjansoftware.com
"John" <Jo**@nospam.infovis.co.uk> wrote in message news:uP**************@TK2MSFTNGP14.phx.gbl... Is it possible to save all properties of controls without even knowing what they are?
Thanks
Regards
"Cor Ligthert" <no************@planet.nl> wrote in message news:e6**************@TK2MSFTNGP12.phx.gbl... 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
You could use resource files (.resx).
"John" <Jo**@nospam.infovis.co.uk> skrev i melding
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steven |
last post by:
H
I'm struggling to think this one through
At run time I want to be able to read a layout HTML file from a database which includes tags for modules, e.g
...
|
by: John Tyce |
last post by:
The problem that I am now having, involves refreshing controls. I have allot of text boxes, several combo boxes and grids. These controls are showing live data from an Oracle database. I have dates...
|
by: Invalidlastname |
last post by:
Hi,
We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
|
by: Greg |
last post by:
In my ASP.NET application I have a button that when pressed, data needs to
be saved based on what the user typed in. I have other controls on the same
page that should be updated as a result of the...
|
by: Ben |
last post by:
Hi, I would like to use web user contols for header and footer controls.
The problem I'm having is that we're using tables for layout. (thanks for
any pro css solutions, but thats' a different...
|
by: Sachi |
last post by:
Hi,
I am looking for a optimized design for my problem.
Purpose : Need to give a UI where user can select the layout they want.
Initially we also need to give them one possible way to define...
|
by: VJ |
last post by:
I am looking to have 2 Tab Controls on a Windows Forms.. One with Tabs on
Top and another with Tabs on the side... I want them both to occupy the
entire area of the form, but I need the Tab...
|
by: npverni |
last post by:
I have a fairly complex form that needs to load and maintain the state
of several different dynamic user controls. Here is the workflow:
1) A series of editable user controls (each containing...
|
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= |
last post by:
Hi all
It is maybe a stupid question, but I have some
trouble with Inheritance.
For example:
I create a new class with one form.
On this form I place on the bottom a Panel
and on this Panel...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |