473,394 Members | 1,679 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,394 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 1577
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...
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
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
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...

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.