473,325 Members | 2,480 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,325 software developers and data experts.

Size and location change

Hi
This is my simple code:

public Form1()

{

this.Size = configFile.getSize();

this.Location = configFile.getLocation(this.Size.Width);

this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form 1_Closing);

InitializeComponent();

}

When the size and location is set, everything is ok.
But after InitializeComponent() they are set to the default values - ones
that i have set in properties window.

Why this happens and where should i set new values.
Thx
Mar 17 '06 #1
4 2382
Hi,

InitializeComponent sets the size and location specified in the Design
window of Visual Studio.
If you want to modify this in code, put your code AFTER InitializeComponent

On Fri, 17 Mar 2006 14:35:55 +0100, PiotrKolodziej
<pi*************@gmail.com> wrote:
Hi
This is my simple code:

public Form1()

{

this.Size = configFile.getSize();

this.Location = configFile.getLocation(this.Size.Width);

this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form 1_Closing);

InitializeComponent();

}

When the size and location is set, everything is ok.
But after InitializeComponent() they are set to the default values - ones
that i have set in properties window.

Why this happens and where should i set new values.
Thx


--
Happy Coding!
Morten Wennevik [C# MVP]
Mar 17 '06 #2
If you use the constructor add all your code after InitializeComonent method
call. Other alternatice is to move your code in OnLoad.
--
HTH
Stoitcho Goutsev (100)

"PiotrKolodziej" <pi*************@gmail.com> wrote in message
news:b4***************************@news.chello.pl. ..
Hi
This is my simple code:

public Form1()

{

this.Size = configFile.getSize();

this.Location = configFile.getLocation(this.Size.Width);

this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form 1_Closing);

InitializeComponent();

}

When the size and location is set, everything is ok.
But after InitializeComponent() they are set to the default values - ones
that i have set in properties window.

Why this happens and where should i set new values.
Thx

Mar 17 '06 #3
On Fri, 17 Mar 2006 14:35:55 +0100, PiotrKolodziej wrote:
public Form1()

{

this.Size = configFile.getSize();

this.Location = configFile.getLocation(this.Size.Width);

this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form 1_Closing);

InitializeComponent();

}

When the size and location is set, everything is ok.
But after InitializeComponent() they are set to the default values - ones
that i have set in properties window.

Why this happens and where should i set new values.


In the designer, set the StartPosition propery to Manual. Then in your
constructor, set the size and location of your form *after* the
InitializeComponent() call (actually, there is a very clear comment in the
auto-generated constructor that instructs you to do that).
Mar 17 '06 #4
Thank you all.
Mar 17 '06 #5

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

Similar topics

3
by: | last post by:
Hi,all I want to change Control's size&location in runtime ,(C#) but i dont know how to do! :(so, can you provide me with document about this. my email: zhonghua@rinpak.com.cn ...
4
by: JMUApache | last post by:
Hi, A have a problem with Inhreit Control. I try to Change its Size in Construct Function, And it works. Code Here: -------------------------------------------------- public class...
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...
3
by: Boki | last post by:
Hi All, When put in a webbowser box into form, there is no adjustable anchor for user to adjust size if he/she want. I use an external Hscroll for adjustment. The problem is I have two...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.