473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Writing/reading control properties to a file

Hi

I am trying to save settings of controls on my form to a file so I can read
them back later and recreate the controls on the form. I have figured out
how to go through all controls and get their properties (see code below).
What I am not sure is; how and what type of file format I need to save the
info to and how to read it back. Would appreciate any help on that. A code
snippet would be very much appreciated.

Many thanks

Regards
For Each Ctrl In rootControl.Controls
Props = TypeDescriptor.GetProperties(Ctrl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsable Then
PropName = Prop.Name
PropValue = Prop.GetValue(Ctrl)
' Write control properties to a file - how?
End If
Next
Next
Jun 24 '07 #1
6 1039
i personally would just serialize and deserialize the hole control to disk ,
much easier

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi

I am trying to save settings of controls on my form to a file so I can
read them back later and recreate the controls on the form. I have figured
out how to go through all controls and get their properties (see code
below). What I am not sure is; how and what type of file format I need to
save the info to and how to read it back. Would appreciate any help on
that. A code snippet would be very much appreciated.

Many thanks

Regards
For Each Ctrl In rootControl.Controls
Props = TypeDescriptor.GetProperties(Ctrl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsable Then
PropName = Prop.Name
PropValue = Prop.GetValue(Ctrl)
' Write control properties to a file - how?
End If
Next
Next

Jun 24 '07 #2
Presumably deserialize requires knowing what object type to expect when
reading file? My problem is my appe will not know beforehand what objects to
expect. Would deserialize still work?

Thanks

Regards

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>i personally would just serialize and deserialize the hole control to disk
, much easier

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi

I am trying to save settings of controls on my form to a file so I can
read them back later and recreate the controls on the form. I have
figured out how to go through all controls and get their properties (see
code below). What I am not sure is; how and what type of file format I
need to save the info to and how to read it back. Would appreciate any
help on that. A code snippet would be very much appreciated.

Many thanks

Regards
For Each Ctrl In rootControl.Controls
Props = TypeDescriptor.GetProperties(Ctrl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsable Then
PropName = Prop.Name
PropValue = Prop.GetValue(Ctrl)
' Write control properties to a file - how?
End If
Next
Next


Jun 24 '07 #3
Just to clear this up..I need to read the file (xml if it may) then see what
control is specified (without knowing which one to expect beforehand) and
its properties and then cerate the relevant control on the form. Basically I
am trying to create a sort of a template system for forms with different
settings for controls and their respective properties for different clients.
Just so I don't have to have separate hard coded versions of forms for each
clients and one form would do with separate template (xml?) file for each
client.

Thanks

Regards

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>i personally would just serialize and deserialize the hole control to disk
, much easier

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi

I am trying to save settings of controls on my form to a file so I can
read them back later and recreate the controls on the form. I have
figured out how to go through all controls and get their properties (see
code below). What I am not sure is; how and what type of file format I
need to save the info to and how to read it back. Would appreciate any
help on that. A code snippet would be very much appreciated.

Many thanks

Regards
For Each Ctrl In rootControl.Controls
Props = TypeDescriptor.GetProperties(Ctrl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsable Then
PropName = Prop.Name
PropValue = Prop.GetValue(Ctrl)
' Write control properties to a file - how?
End If
Next
Next


Jun 24 '07 #4
well for serializing and deserializing you must at least have an interface
if you can provide a generic interface in your situation ...... then it is
possible

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
Presumably deserialize requires knowing what object type to expect when
reading file? My problem is my appe will not know beforehand what objects
to expect. Would deserialize still work?

Thanks

Regards

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>i personally would just serialize and deserialize the hole control to disk
, much easier

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Hi

I am trying to save settings of controls on my form to a file so I can
read them back later and recreate the controls on the form. I have
figured out how to go through all controls and get their properties (see
code below). What I am not sure is; how and what type of file format I
need to save the info to and how to read it back. Would appreciate any
help on that. A code snippet would be very much appreciated.

Many thanks

Regards
For Each Ctrl In rootControl.Controls
Props = TypeDescriptor.GetProperties(Ctrl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsable Then
PropName = Prop.Name
PropValue = Prop.GetValue(Ctrl)
' Write control properties to a file - how?
End If
Next
Next



Jun 24 '07 #5
Hi Michael

Is there a code link I can check?

Thanks

Regards

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:um*************@TK2MSFTNGP05.phx.gbl...
well for serializing and deserializing you must at least have an
interface
if you can provide a generic interface in your situation ...... then it
is possible

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Presumably deserialize requires knowing what object type to expect when
reading file? My problem is my appe will not know beforehand what objects
to expect. Would deserialize still work?

Thanks

Regards

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>>i personally would just serialize and deserialize the hole control to
disk , much easier

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
Hi

I am trying to save settings of controls on my form to a file so I can
read them back later and recreate the controls on the form. I have
figured out how to go through all controls and get their properties
(see code below). What I am not sure is; how and what type of file
format I need to save the info to and how to read it back. Would
appreciate any help on that. A code snippet would be very much
appreciated.

Many thanks

Regards
For Each Ctrl In rootControl.Controls
Props = TypeDescriptor.GetProperties(Ctrl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsable Then
PropName = Prop.Name
PropValue = Prop.GetValue(Ctrl)
' Write control properties to a file - how?
End If
Next
Next



Jun 24 '07 #6
well i use this
''' <summary>
''' maakt van een byte array een object
''' </summary>
''' <param name="Argdata">de ruwe binaire data </param>
''' <returns></returns>
Private Function DeSerialize(ByVal Argdata() As Byte) As Object
Dim m As New MemoryStream(Argdata)
Dim b As New BinaryFormatter()
m.Seek(0, 0) 'start
Return b.Deserialize(m)
End Function
''' <summary>
''' Maakt van een Object (foo) een byte array .
''' </summary>
''' <param name="Argdata">argdata als foo object</param>
''' <returns></returns>
Private Function Serialize(ByVal Argdata As Object) As Byte()
Dim b As New BinaryFormatter
Dim m As New MemoryStream
b.Serialize(m, Argdata)
m.Seek(0, 0) 'start
Return m.ToArray
End Function
to serialize and deserialize objects in my projects ( i store the byte array
in a sql server , but just as easy you could write it to a file )
example

<Serializable()_
Private Structure Selection
Dim ControlSoort As ControlType
Dim Vals As Object
Dim Tooltip As String
Dim Dsc As String
End Structure
Dim vals As Selection = CType(DeSerialize(CType(drH.Item("ControlWrd"),
Byte())), Selection)
where drH.Item("ControlWrd") is the binary data storded in my database , i
have chosen explicitly not to use XML as Binary serialization and
deserialization is
1. more compact 2. much faster 3. i do not want people easy to see what is
stored in the fields
HTH

Michel Posseth

"John" wrote:
Hi Michael

Is there a code link I can check?

Thanks

Regards

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:um*************@TK2MSFTNGP05.phx.gbl...
well for serializing and deserializing you must at least have an
interface
if you can provide a generic interface in your situation ...... then it
is possible

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
Presumably deserialize requires knowing what object type to expect when
reading file? My problem is my appe will not know beforehand what objects
to expect. Would deserialize still work?

Thanks

Regards

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
i personally would just serialize and deserialize the hole control to
disk , much easier

regards

Michel
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi

I am trying to save settings of controls on my form to a file so I can
read them back later and recreate the controls on the form. I have
figured out how to go through all controls and get their properties
(see code below). What I am not sure is; how and what type of file
format I need to save the info to and how to read it back. Would
appreciate any help on that. A code snippet would be very much
appreciated.

Many thanks

Regards
For Each Ctrl In rootControl.Controls
Props = TypeDescriptor.GetProperties(Ctrl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsable Then
PropName = Prop.Name
PropValue = Prop.GetValue(Ctrl)
' Write control properties to a file - how?
End If
Next
Next




Jun 25 '07 #7

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

Similar topics

7
by: Jason Heyes | last post by:
I have a class with an expensive copy, read and write. There are many objects of this class used throughout my program. What kind of encapsulation of this class do I use to make sure copy, read and...
1
by: J-S | last post by:
Hi, I'm a student and new to the .net framework. What is the best way to save configuration properties (not user specific) for a C# application? I read a few messages talking about using...
1
by: Mike Preston | last post by:
Has anybody used something like DSOFile to read and write properties of folders on an NTFS drive? This will be for my own use, so things like security don't really matter to the project at hand. ...
3
by: Arne Beruldsen | last post by:
How do you read the serial number to a hard drive? Thanks...Arne
19
by: Noozer | last post by:
I need to keep my application settings in a file that users can copy/backup/etc. Before I start using the old INI file standard, is there any easy way to use XML files to hold application...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
6
by: John | last post by:
Hi I am trying to save settings of controls on my form to a file so I can read them back later and recreate the controls on the form. I have figured out how to go through all controls and get...
5
by: David Veeneman | last post by:
I'm opening a JPG file to read and write its EXIF properties. I'm using very simple code to open the file: myBitmap = new Bitmap(filePath); Reading and writing the properties is working fine,...
4
by: pbj2009 | last post by:
Hello all: I'm pretty stumped on this one. I'm not looking for Code, I'm just trying to figure out the best way to start this since I am new to reading and writing from files. I can't figure out...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.