473,386 Members | 1,720 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,386 software developers and data experts.

saving Form.ClientSize in settings

hi,
i was trying to save the window size of my app using the generated
Settings class of Visual C# 2005 Express. for some reason, the stored
size was bigger from the actual size, so each time i start the app, it's
bigger than before, until it fills the screen (1024*768). the odd thing
is, that it works just fine in the IDE, and if i install it on a
different computer, and even if i use the executable produced by the IDE
instead of the one deployed by the MSI file compiled by the deployment
project.

since i have the Express edition at home, i took the app project to
work, and added a deployment project to the solution there, with a Team
Suite edition. then i ran the MSI on the work machine, and it worked
just fine (with higher resolution). when i took the MSI back home and
installed it, i received the symptom i described.

as mentioned in the subject, the actual value saved was that of the
form's ClientSize property. in the debugger, it seems like the expected
size is loaded, and then saved correctly. only outside the IDE it acts
weird.

i don't know how important that is, but this is an upgrade from a
previous version. the machine at work didn't have the previous version,
which was based on .NET 1.1. my home machine did, and this version,
based on .NET 2.0, seems to have upgraded it cleanly, except for that
problem.

here's some code:
in the form's constructor:

ClientSize = Settings.Default.ClientSize;

in a method called from the OnFormClosing() override:

Settings.Default.ClientSize = ClientSize;
Settings.Default.Save();

Tsahi
Jul 29 '07 #1
3 2540
* Tsahi Asher wrote, On 29-7-2007 23:39:
hi,
i was trying to save the window size of my app using the generated
Settings class of Visual C# 2005 Express. for some reason, the stored
size was bigger from the actual size, so each time i start the app, it's
bigger than before, until it fills the screen (1024*768). the odd thing
is, that it works just fine in the IDE, and if i install it on a
different computer, and even if i use the executable produced by the IDE
instead of the one deployed by the MSI file compiled by the deployment
project.

since i have the Express edition at home, i took the app project to
work, and added a deployment project to the solution there, with a Team
Suite edition. then i ran the MSI on the work machine, and it worked
just fine (with higher resolution). when i took the MSI back home and
installed it, i received the symptom i described.

as mentioned in the subject, the actual value saved was that of the
form's ClientSize property. in the debugger, it seems like the expected
size is loaded, and then saved correctly. only outside the IDE it acts
weird.

i don't know how important that is, but this is an upgrade from a
previous version. the machine at work didn't have the previous version,
which was based on .NET 1.1. my home machine did, and this version,
based on .NET 2.0, seems to have upgraded it cleanly, except for that
problem.

here's some code:
in the form's constructor:

ClientSize = Settings.Default.ClientSize;

in a method called from the OnFormClosing() override:

Settings.Default.ClientSize = ClientSize;
Settings.Default.Save();
My guess is that you have to set the ClientSize in the Form.Show event,
or after the InitializeComponent in the Form.Load event has run. The
constructor is too early in the forms lifecycle. Otherwise it'll just
get overridden.

Jesse
Jul 30 '07 #2
φιθεθ Jesse Houwing:
* Tsahi Asher wrote, On 29-7-2007 23:39:
>hi,
i was trying to save the window size of my app using the generated
Settings class of Visual C# 2005 Express. for some reason, the stored
size was bigger from the actual size, so each time i start the app,
it's bigger than before, until it fills the screen (1024*768). the odd
thing is, that it works just fine in the IDE, and if i install it on a
different computer, and even if i use the executable produced by the
IDE instead of the one deployed by the MSI file compiled by the
deployment project.

since i have the Express edition at home, i took the app project to
work, and added a deployment project to the solution there, with a
Team Suite edition. then i ran the MSI on the work machine, and it
worked just fine (with higher resolution). when i took the MSI back
home and installed it, i received the symptom i described.

as mentioned in the subject, the actual value saved was that of the
form's ClientSize property. in the debugger, it seems like the
expected size is loaded, and then saved correctly. only outside the
IDE it acts weird.

i don't know how important that is, but this is an upgrade from a
previous version. the machine at work didn't have the previous
version, which was based on .NET 1.1. my home machine did, and this
version, based on .NET 2.0, seems to have upgraded it cleanly, except
for that problem.

here's some code:
in the form's constructor:

ClientSize = Settings.Default.ClientSize;

in a method called from the OnFormClosing() override:

Settings.Default.ClientSize = ClientSize;
Settings.Default.Save();

My guess is that you have to set the ClientSize in the Form.Show event,
or after the InitializeComponent in the Form.Load event has run. The
constructor is too early in the forms lifecycle. Otherwise it'll just
get overridden.

Jesse
thanks, getting that at the OnLoad event override fixed the problem.

tsahi
Jul 30 '07 #3
* Tsahi Asher wrote, On 30-7-2007 22:51:
φιθεθ Jesse Houwing:
>* Tsahi Asher wrote, On 29-7-2007 23:39:
>>hi,
i was trying to save the window size of my app using the generated
Settings class of Visual C# 2005 Express. for some reason, the stored
size was bigger from the actual size, so each time i start the app,
it's bigger than before, until it fills the screen (1024*768). the
odd thing is, that it works just fine in the IDE, and if i install it
on a different computer, and even if i use the executable produced by
the IDE instead of the one deployed by the MSI file compiled by the
deployment project.

since i have the Express edition at home, i took the app project to
work, and added a deployment project to the solution there, with a
Team Suite edition. then i ran the MSI on the work machine, and it
worked just fine (with higher resolution). when i took the MSI back
home and installed it, i received the symptom i described.

as mentioned in the subject, the actual value saved was that of the
form's ClientSize property. in the debugger, it seems like the
expected size is loaded, and then saved correctly. only outside the
IDE it acts weird.

i don't know how important that is, but this is an upgrade from a
previous version. the machine at work didn't have the previous
version, which was based on .NET 1.1. my home machine did, and this
version, based on .NET 2.0, seems to have upgraded it cleanly, except
for that problem.

here's some code:
in the form's constructor:

ClientSize = Settings.Default.ClientSize;

in a method called from the OnFormClosing() override:

Settings.Default.ClientSize = ClientSize;
Settings.Default.Save();

My guess is that you have to set the ClientSize in the Form.Show
event, or after the InitializeComponent in the Form.Load event has
run. The constructor is too early in the forms lifecycle. Otherwise
it'll just get overridden.

Jesse
thanks, getting that at the OnLoad event override fixed the problem.

tsahi
You're welcome.

Jesse
Jul 30 '07 #4

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

Similar topics

6
by: K.N.Ranjit | last post by:
Here's my coding again: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents...
3
by: Xwire | last post by:
Can anyone explain why when i set the .ClientSize of a form, and then check the .ClientSize when the resize event fires, it is slightly off, generally 20(varys) pixels in the height but not...
4
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and...
0
by: Patrick Lioi | last post by:
We have form that is used as the base class of all of our forms, let's call it BaseApplicationForm. We have another form, say ChildApplicationForm that inherits from BaseApplicationForm. The...
0
by: Paul | last post by:
I have a windows form with ApplicationSettings bound to the location, clientsize, and windowstate. Theses settings were created and stored using the settings designer. The location, for instance,...
14
by: Galen Somerville | last post by:
My current screen resolution is set to 1024 x 768. My form size always comes up as 1032 x 748. I have tried the help sample ' Retrieve the working rectangle from the Screen class ' using the...
6
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I want to implement the following: If the user clicks on the border of a form, then I want to show a box around the form that represents the form's bounds. As the user moves the mouse only the...
0
by: =?Utf-8?B?VHJhY2tz?= | last post by:
Does the toolstripcontainer etc work at all? I want to save the settings for the toolstrip positions in my app so they start up with the saved positions. Tried using: ...
3
by: RobEveryThingIsPossible | last post by:
IN VISTA MS Access 2000 Printer Settings Not Saving With Vista Bus. The printer settings (Label or Env.) keep on change back to another setting after saving them on a report or form, when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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,...

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.