473,669 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Anyone have a HOWTO on this requirement?

Hi,

I would like to specify a group of Properties/Fields of some objects on a
WinForm, for which I would like to have the values loaded from the Registry,
and saved to it upon closing of the form.

ie. the form's Size, the positions and sizes of some controls on that form
should "remember" their state across the sessions of a user.

I thought a Hashtable would be a good idea to set the name of the
registry-entry as the Key name of the HT-entry, and the key-value would be
the value of the property/field.

but if I do this:
myHT.add("Form_ Size", this.Size);
of course only the current-value of the size would be saved - or better, if
I changed the value in the hashtable to another size, the Form.Size would
not get updated. Are delegates suitable for properties/fields, or do I have
to do it another way? There must be a way to accomplish this!

Thanks for any input on this!

regards, Tilli
Nov 16 '05 #1
5 1941
Hi,

You could also use a XML file local to your application. If you for some
reason want to use the HashTable you can serialize it with no big problem I
think.
It will be your code responsability to assign/update the values when the
form is created/closed though.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tilfried Weissenberger" <ti***@weissenb erger.at> wrote in message
news:10******** *******@news.ai c.at...
Hi,

I would like to specify a group of Properties/Fields of some objects on a
WinForm, for which I would like to have the values loaded from the Registry, and saved to it upon closing of the form.

ie. the form's Size, the positions and sizes of some controls on that form
should "remember" their state across the sessions of a user.

I thought a Hashtable would be a good idea to set the name of the
registry-entry as the Key name of the HT-entry, and the key-value would be
the value of the property/field.

but if I do this:
myHT.add("Form_ Size", this.Size);
of course only the current-value of the size would be saved - or better, if I changed the value in the hashtable to another size, the Form.Size would
not get updated. Are delegates suitable for properties/fields, or do I have to do it another way? There must be a way to accomplish this!

Thanks for any input on this!

regards, Tilli

Nov 16 '05 #2
Create two methods
i.e.
SavePosition , RestorePosition

Call SavePosition when the form closes (OnClose) and call the
RestorePosition when the form loads...

In SavePosition use the RegistryKey class to create/check for the existance
of your custom key and simply store the X, Y, Heihght, Width as 4 key value
pairs to that entry. Then in the RestorePosition again open the key if it
exists and load those 4 values. You can name them any way you like. Set
your Forms size and position and your done

JIM
"Tilfried Weissenberger" <ti***@weissenb erger.at> wrote in message
news:10******** *******@news.ai c.at...
Hi,

I would like to specify a group of Properties/Fields of some objects on a
WinForm, for which I would like to have the values loaded from the Registry, and saved to it upon closing of the form.

ie. the form's Size, the positions and sizes of some controls on that form
should "remember" their state across the sessions of a user.

I thought a Hashtable would be a good idea to set the name of the
registry-entry as the Key name of the HT-entry, and the key-value would be
the value of the property/field.

but if I do this:
myHT.add("Form_ Size", this.Size);
of course only the current-value of the size would be saved - or better, if I changed the value in the hashtable to another size, the Form.Size would
not get updated. Are delegates suitable for properties/fields, or do I have to do it another way? There must be a way to accomplish this!

Thanks for any input on this!

regards, Tilli

Nov 16 '05 #3
One other thing I should mention though is that you might want to check
first to see if the form is Maximized before saving its size, becuase you
probably do not want to restore a froms size to the max window size becuase
it confuses users. Usually I test for this and if it is maxed I set it to
some smaller size like 800x600 or some such size.

JIM
"james" <no****@hyperco n.net> wrote in message
news:uL******** ******@TK2MSFTN GP09.phx.gbl...
Create two methods
i.e.
SavePosition , RestorePosition

Call SavePosition when the form closes (OnClose) and call the
RestorePosition when the form loads...

In SavePosition use the RegistryKey class to create/check for the existance of your custom key and simply store the X, Y, Heihght, Width as 4 key value pairs to that entry. Then in the RestorePosition again open the key if it
exists and load those 4 values. You can name them any way you like. Set
your Forms size and position and your done

JIM
"Tilfried Weissenberger" <ti***@weissenb erger.at> wrote in message
news:10******** *******@news.ai c.at...
Hi,

I would like to specify a group of Properties/Fields of some objects on a WinForm, for which I would like to have the values loaded from the

Registry,
and saved to it upon closing of the form.

ie. the form's Size, the positions and sizes of some controls on that form should "remember" their state across the sessions of a user.

I thought a Hashtable would be a good idea to set the name of the
registry-entry as the Key name of the HT-entry, and the key-value would be the value of the property/field.

but if I do this:
myHT.add("Form_ Size", this.Size);
of course only the current-value of the size would be saved - or better,

if
I changed the value in the hashtable to another size, the Form.Size would not get updated. Are delegates suitable for properties/fields, or do I

have
to do it another way? There must be a way to accomplish this!

Thanks for any input on this!

regards, Tilli


Nov 16 '05 #4
Thanks all for your responses.

Unfortunately my example of the size/position is just for demonstration
purpose. I inherit from a common form, which does that for me already. I
just want to be able to add more attributes, such as column-width of grids,
width of dynamically positioned sliders etc. - I want to be able to pass a
list of objects/properties to a function which will then either save the
state to the registry (that's the easy part), or load it from there back
into the properties (that's where I have the problem)!

so it's not a conventional solution I require - I guess I have to use
Reflection to do what I want - someone out there must know how this can be
accomplished!

Thanks for any further input!

regards, Tilli
Nov 16 '05 #5
You can just manually save and load the properties of the controls you want
to save. Reflection isn't going to help you if you dont know what you are
storing because you may attempt to store things you dont need to store and
re-storing them might cause issues if done in an incorrect order. Basically
what I would do is create an interface like IRestorable or some such and
then subclass all the controls you want to be able to restore, and implement
that interface in the control. Then your form can just go through all its
controls and call the store/restore method. Each control should know then
what it needs to do and how it needs to do it.

By the way, I use DevExpress's tools which can all store/restore themselves
JIM
"Tilfried Weissenberger" <ti***@weissenb erger.at> wrote in message
news:10******** *******@news.ai c.at...
Thanks all for your responses.

Unfortunately my example of the size/position is just for demonstration
purpose. I inherit from a common form, which does that for me already. I
just want to be able to add more attributes, such as column-width of grids, width of dynamically positioned sliders etc. - I want to be able to pass a
list of objects/properties to a function which will then either save the
state to the registry (that's the easy part), or load it from there back
into the properties (that's where I have the problem)!

so it's not a conventional solution I require - I guess I have to use
Reflection to do what I want - someone out there must know how this can be
accomplished!

Thanks for any further input!

regards, Tilli

Nov 16 '05 #6

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

Similar topics

4
2870
by: Josef Sachs | last post by:
Is Andrew Kuchling's regex-to-re HOWTO available anywhere? I've found the following (dead) links on various Web pages: http://py-howto.sourceforge.net/regex-to-re/regex-to-re.html http://starship.skyport.net/crew/amk/regex/regex-to-re.html http://www.python.org/doc/howto/regex-to-re/ http://www.amk.ca/python/howto/regex-to-re/ Thanks in advance.
3
4141
by: googlemike | last post by:
You may have a requirement that you cannot change where you have old apps, such as Delphi 3 apps (in my case), that must hobble along until the BIG migration money comes into migrate to something better. And those old apps may require that you keep SQL 6.5 on the backend. In my case, that's the case, unfortunately. And Microsoft has completely dried up support for it. You may find that you can't install SQL 6.5 Enterprise Edition on...
3
11554
by: Plumer | last post by:
Good morning everyone Using C# I create a bog-standard System.Data.DataTable which I then Add to a System.Data.Dataset (At the moment I'm in the guess-and-test phase so the table has only one field called "ID" which is Int32.) I need to save this table to an SQL Server database. The Dataset/DataAdapter approach does not seem to provide for this requirement. The logic appears to be based on the
0
923
by: Dan Sikorsky | last post by:
In my Login.aspx, how can I turn off the requirement for using strong passwords? Then web app is on a LAN not connected to the internet. -- Dan Sikorsky, MSCS BSCE BAB
1
2560
by: Shun | last post by:
Hello, My requirement is to develop an Employee Attendance Register. For ex: I am in some X country and my office is in Y country. now my requirement is i want to check the employees present and also there previous days attendance(i.e complete Month employee Attendance). I am farwarding in 2 ways, 1. By searching in Google for any free attendance register software.
7
20319
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables, if they do not already exist. In terms of ASP/ADO, that would be fine in a SQL Server Sense by a simply ASP/Server-Side JavaScript as such: var cnTemp = Server.CreateObject("ADODB.Connection");
0
1467
by: nrworld | last post by:
Hi, I have a requirement to find the users logged in to a XP system using a C# service which is running as SYSTEM service. An additional requirement is to start an application on the Active Desktop users as that user. The application should be spawned by the service, is this possible if the user account is password protected and The service doesn't know the password of that user ?? Please help.
8
5411
by: Helmut Jarausch | last post by:
Hi, I need to hash arrays of integers (from the hash module). So, I have to derive from array and supply a __hash__ method. But how to hash an array (of fixed length, say 25)? What I need is a function which maps a tuple of 25 integers into 1 integer with good hashing properties. Does anybody know such a thing?
0
8384
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
8896
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8810
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
8659
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...
1
6211
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
5683
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
4208
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
4387
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1790
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.