473,657 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' Write control properties to a file - how?
End If
Next
Next
Jun 24 '07 #1
6 1598
i personally would just serialize and deserialize the hole control to disk ,
much easier

regards

Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2******** ********@TK2MSF TNGP04.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.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' 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.c omwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>i personally would just serialize and deserialize the hole control to disk
, much easier

regards

Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2******** ********@TK2MSF TNGP04.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.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' 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.c omwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>i personally would just serialize and deserialize the hole control to disk
, much easier

regards

Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2******** ********@TK2MSF TNGP04.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.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' 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.in fovis.co.ukschr eef in bericht
news:%2******** ********@TK2MSF TNGP05.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.c omwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>>i personally would just serialize and deserialize the hole control to disk
, much easier

regards

Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2******* *********@TK2MS FTNGP04.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.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' 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.c omwrote in message
news:um******** *****@TK2MSFTNG P05.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.in fovis.co.ukschr eef in bericht
news:%2******** ********@TK2MSF TNGP05.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.c omwrote in message
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>>i personally would just serialize and deserialize the hole control to
disk , much easier

regards

Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2****** **********@TK2M SFTNGP04.phx.gb l...
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
appreciate d.

Many thanks

Regards
For Each Ctrl In rootControl.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' 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(ByV al Argdata() As Byte) As Object
Dim m As New MemoryStream(Ar gdata)
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(DeSeriali ze(CType(drH.It em("ControlWrd" ),
Byte())), Selection)
where drH.Item("Contr olWrd") 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.c omwrote in message
news:um******** *****@TK2MSFTNG P05.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.in fovis.co.ukschr eef in bericht
news:%2******** ********@TK2MSF TNGP05.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.c omwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
i personally would just serialize and deserialize the hole control to
disk , much easier

regards

Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2******* *********@TK2MS FTNGP04.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.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' 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
1821
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 write are optimised in my program? Thanks.
1
17457
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 XML to save properties. I read about using app.config, but it seems you have to manually edit the file in order to change its values, and I don't want those values hard coded. I'm trying to avoid the registry. In my reading I have concluded that...
3
2171
by: Arne Beruldsen | last post by:
How do you read the serial number to a hard drive? Thanks...Arne
19
2523
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 settings? What is the standard method of saving user settings for VB.Net apps?
6
5260
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
1045
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 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
5
2102
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, but when I go to save the file, I'm getting an exception that reads "A generic error occurred in GDI+." Here's the code I'm using to save the file back to the same name it was opened from:
4
3212
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 what section (main/btnOpen/frmExceptionsLoad) to put the code and all tutorials have either reading from or writing to and I am confused about putting it together along with the calculations of course. I have to write a program that when I click a...
0
8305
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
8730
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...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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
7321
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
6163
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
4151
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...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.