473,765 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save FormSettings of MULTIPLE Forms in XML file!? (VB.NET)

Hi,

I found some examples for storing the FormSettings of a Form in an XML-file,
but none of these could match my criteria: What I am looking for is the
possibility to save the FormSettings of multiple Instances of 1 form.

I have a Form frmSource from which I have multiple Instances, each with a
unique Identifier. So when I Load or Close a specific instance, I want to
load or save the Settings (Top, Height, Width, etc) in an XML-file. I need
to find a way to search with the unique Identifier of the Form in the
XML-file.

Anybody had some examples of this? I thought maybe making a DataSet with the
settings stored in it and writing and reading the XML-file fromd the
DataSet? But how do I fill that DataSet than with my FormSettings?

I'm pretty new to XML (and VB.NET also), so any help would be appreciated!
Thanks in advance!!

DraguVaso
Nov 20 '05 #1
2 3121
Create a dataset sounds like a good idea, and then you
could persist this on program shutdown and reopen when the
program opens. You could also define a class that had
properties corresponding to the form attributes you wanted
to keep track of and serialize/ deserialize this when the
program closed/ opened.

With respect to the dataset method you could try the
following:
Add a schema to your project and define a table with
column headings corresponding to the form attributes you
want to record.

Build a dataset based on the above defined schema.

To Add Initialisation Data To DataSet
Dim NewDataRow As DataRow
For Each FormToRecord
MyNewDataRow = MyFormDataSet.T ables(0).NewRow
MyNewDataRow(Co lumnIndexes)= PropertyValues
MyFormDataSet.T ables(0).Add(Ne wRow)
Next

Create a procedures to call from open and close form
events. Example close event is given below:

Sub FormClose(ByVal FormBeingClosed As Form)

Dim EndLoop As Boolean= False
IENumRow = MyFormDataSet.T ables
(0).Rows.GetEnu merator 'Assumes Only One Row
Do While IENumRow.MoveNe xt Or Not EndLoop
If IENumRow.Curren t(Index Corresponding to
column containing identifier) = FormBeingClosed ID Then
IEnumRow.Curren t(IndexOfProper ty1Column)=
FormBeingClosed .RelevantProper ty
EndLoop= True
End If
Loop
'Use The Index To Update The Current DataRow
MyFormDataSet.T ables(0).Row(Co unt)
on the open and load events for each form.

-----Original Message-----
Hi,

I found some examples for storing the FormSettings of a Form in an XML-file,but none of these could match my criteria: What I am looking for is thepossibility to save the FormSettings of multiple Instances of 1 form.
I have a Form frmSource from which I have multiple Instances, each with aunique Identifier. So when I Load or Close a specific instance, I want toload or save the Settings (Top, Height, Width, etc) in an XML-file. I needto find a way to search with the unique Identifier of the Form in theXML-file.

Anybody had some examples of this? I thought maybe making a DataSet with thesettings stored in it and writing and reading the XML- file fromd theDataSet? But how do I fill that DataSet than with my FormSettings?
I'm pretty new to XML (and VB.NET also), so any help would be appreciated!Thanks in advance!!

DraguVaso
.

Nov 20 '05 #2
I use the class (code bellow) to write keys on app.exe.config thats is
loaded at startup
You can choose under what key you want to store any settings (set Identifier
from de calling routine)
One remark: While developing it writes on app.exe.config but try to not load
setings on the app.config so i'll need to manuallly copy settings on
app.exe.config to app.config to work on IDE
Hope it Helps
Marcos
Form Code:
*************** **
Imports System.Configur ation
Imports myApp.myUtiliti es
Public Identifier as Integer
Load....
Me.Width = CType(Reader.Ge tValue(Identifi er.tostring & ".Width",
GetType(System. Int32)), Int32)
end sub

Closing....
Dim Writer As New AppSettingsWrit er()
Writer(Identifi er.tostring & ".Width") = CStr(Me.Width)
Writer.SaveFile ()
end sub

Class:
*************** **
Imports System
Imports System.Xml

Namespace myApp.myUtiliti es
Public Class AppSettingsWrit er
Private configFileName As String
Private document As XmlDocument

Public Sub New()
Dim asmy As System.Reflecti on.Assembly
Dim tempName As String
asmy = System.Reflecti on.Assembly.Get EntryAssembly()
tempName = asmy.Location
configFileName = tempName & ".config"
document = New XmlDocument()
document.Load(c onfigFileName)
End Sub

Default Public WriteOnly Property Value(ByVal key As String) As String
Set(ByVal Value As String)
Dim Query As String
Dim Node As XmlNode
Dim Root As XmlNode
Dim Attribute1 As XmlNode
Dim Attribute2 As XmlNode

Query = "/configuration/appSettings/add[@key=" & _
Chr(34) & key & Chr(34) & "]"
Node = document.Docume ntElement.Selec tSingleNode(Que ry)
If Not Node Is Nothing Then
Node.Attributes .GetNamedItem(" value").Value = Value
Else
Node = document.Create Node(XmlNodeTyp e.Element, "add", "")
Attribute1 = document.Create Node(XmlNodeTyp e.Attribute, "key", "")
Attribute1.Valu e = key
Node.Attributes .SetNamedItem(A ttribute1)
Attribute2 = document.Create Node(XmlNodeTyp e.Attribute, "value", "")
Attribute2.Valu e = Value
Node.Attributes .SetNamedItem(A ttribute2)
Query = "/configuration/appSettings"
Root = document.Docume ntElement.Selec tSingleNode(Que ry)
If Not Root Is Nothing Then
Root.AppendChil d(Node)
Else
Throw New InvalidOperatio nException("Não pude adicionar o nodo ao
arquivo config")
End If
End If
End Set
End Property

Public Sub SaveFile()
document.Save(c onfigFileName)
End Sub
End Class
End Namespace
"DraguVaso" <pi**********@h otmail.com> escreveu na mensagem
news:HH******** *************@p hobos.telenet-ops.be...
Hi,

I found some examples for storing the FormSettings of a Form in an XML-file, but none of these could match my criteria: What I am looking for is the
possibility to save the FormSettings of multiple Instances of 1 form.

I have a Form frmSource from which I have multiple Instances, each with a
unique Identifier. So when I Load or Close a specific instance, I want to
load or save the Settings (Top, Height, Width, etc) in an XML-file. I need
to find a way to search with the unique Identifier of the Form in the
XML-file.

Anybody had some examples of this? I thought maybe making a DataSet with the settings stored in it and writing and reading the XML-file fromd the
DataSet? But how do I fill that DataSet than with my FormSettings?

I'm pretty new to XML (and VB.NET also), so any help would be appreciated!
Thanks in advance!!

DraguVaso

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1396
by: Suresh Kumaran | last post by:
Hi Everyone, I have an application in the following order. Form 1 - User Enters Part Number. After certain basic validation against the file, Form 2 is show with details pertaining to the part number. Form 2 Has menu options like File Open, NEW, SAVE, PRINT
2
1960
by: MJ | last post by:
i have form1 and form2, form1 has a picturebox which i wish to make it accessible to other forms after form2 perform some drawing, it need to call form1.picbox.invalidate() to refresh the picbox, how to declare the picbox?anyone have idea? dim frm1 as form1 frm1 = new form1() frm1.picbox.invalidate
1
385
by: Don | last post by:
hi in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now i'm using vb.net (still getting used to it) and can not figure out how to hide and show forms. my project presently has a few forms but i can only the startup form is visible. i can't hide the startup form or show the other forms. i would like to hide a form when a button is pressed and...
1
2172
by: john sutor | last post by:
I have a main form in a project that launches other forms. How do I ensure that the same form does not get launched twice without killing the orignal form. I other words I need a method to manage multiple forms in an app. Thanks John
8
579
by: TJS | last post by:
what are folks doing to get around limitation of one server form per page ?
6
1916
by: Davids | last post by:
this was impossible to implement on old ASP, is it the same for .Net?
4
2094
by: Mike Kim | last post by:
Hi all, In VB6, you can display multiple forms together at design time. how do you do that in vs.net? as a default, vs.net has a group of tabs and only allow to see one at a time unless you add a new tab group. thanks much.
10
3905
by: SHPsalm139 | last post by:
We have an Access 2K application that uses multiple forms. We currently hardcode the release number in a label on each form but this gets tedious to do each time there's a new release. I thought it would be easy to put the new release number in one spot (a table) and have each form reference that table/release number in a text box that I would add to each form but, apparently, it's not as simple as I expected it to be. Would appreciate...
5
14132
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
3
4095
by: Yehia A.Salam | last post by:
hello, I have to deal with the weird limitation of asp.net, as I need to have multiple forms on my page, well three at least actually, one for the login, one for the search engine, and another one for a certain bulletin list, however asp.net allows only one form per page with runat="server" attribute, I am aware of the visibility issue and that I can hide all of the forms except one but this won't help cause I need all of the three forms...
0
9568
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9835
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.