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

FormStartPosition problem

This one is really stupid Q but I am little not sure why my following code
is doing nothing in load event of form.
this.StartPosition = FormStartPosition.CenterScreen

Rather starting form in center it just opens as default (and that is where
ever)

any pointers?
Nov 17 '05 #1
6 5738
This property can be set in the properties window. Note that, the properties
you set in the properties window does not appear anywhere apart from the
initialize components method which is called from the constructor. With this
in mind, you have to put you code in the constructor after the following line
of code:
InitializeComponent();
good luck!
Belee
"Pohihihi" wrote:
This one is really stupid Q but I am little not sure why my following code
is doing nothing in load event of form.
this.StartPosition = FormStartPosition.CenterScreen

Rather starting form in center it just opens as default (and that is where
ever)

any pointers?

Nov 17 '05 #2
Actually I should have said that it do work using properties but it do not
work if I try to set that at run time.
"Belee" <Be***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
This property can be set in the properties window. Note that, the
properties
you set in the properties window does not appear anywhere apart from the
initialize components method which is called from the constructor. With
this
in mind, you have to put you code in the constructor after the following
line
of code:
InitializeComponent();
good luck!
Belee
"Pohihihi" wrote:
This one is really stupid Q but I am little not sure why my following
code
is doing nothing in load event of form.
this.StartPosition = FormStartPosition.CenterScreen

Rather starting form in center it just opens as default (and that is
where
ever)

any pointers?

Nov 17 '05 #3
Where are you setting it "at runtime"? I would say that anywhere other than
the constructor would not work, since by that time the form has already
"started". You'd probably have to change forms Location property, instead
of StartPosition.

"Pohihihi" <po******@hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
Actually I should have said that it do work using properties but it do not
work if I try to set that at run time.
"Belee" <Be***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
This property can be set in the properties window. Note that, the
properties
you set in the properties window does not appear anywhere apart from the
initialize components method which is called from the constructor. With
this
in mind, you have to put you code in the constructor after the following
line
of code:
InitializeComponent();
good luck!
Belee
"Pohihihi" wrote:
This one is really stupid Q but I am little not sure why my following
code
is doing nothing in load event of form.
this.StartPosition = FormStartPosition.CenterScreen

Rather starting form in center it just opens as default (and that is
where
ever)

any pointers?


Nov 17 '05 #4
because in the load event, the StartPosition has already been read and form
initialized, so changing the StartPosition in form load has no effect.

"Pohihihi" <po******@hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
Actually I should have said that it do work using properties but it do not
work if I try to set that at run time.
"Belee" <Be***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
This property can be set in the properties window. Note that, the
properties
you set in the properties window does not appear anywhere apart from the
initialize components method which is called from the constructor. With
this
in mind, you have to put you code in the constructor after the following
line
of code:
InitializeComponent();
good luck!
Belee
"Pohihihi" wrote:
This one is really stupid Q but I am little not sure why my following
code
is doing nothing in load event of form.
this.StartPosition = FormStartPosition.CenterScreen

Rather starting form in center it just opens as default (and that is
where
ever)

any pointers?


Nov 17 '05 #5
my code is in Form load event. basically what I am doing is that loading
form state from registry. if there is no saved information then it will
default to center of the screen. It does work after Init function (as Belee
suggested) but i want it to function in load event. I can go for location
settings but StartPosition makes things way easy as I do not have to worry
about resolution/screen calculation on client machine.

adition to that what is the reason behind StartPosition not working in any
other place other than in ctor?

Thanks.

"Derrick" <de***********@hotmail.com> wrote in message
news:rM*******************@news20.bellglobal.com.. .
Where are you setting it "at runtime"? I would say that anywhere other
than the constructor would not work, since by that time the form has
already "started". You'd probably have to change forms Location property,
instead of StartPosition.

"Pohihihi" <po******@hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
Actually I should have said that it do work using properties but it do
not work if I try to set that at run time.
"Belee" <Be***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
This property can be set in the properties window. Note that, the
properties
you set in the properties window does not appear anywhere apart from the
initialize components method which is called from the constructor. With
this
in mind, you have to put you code in the constructor after the following
line
of code:
InitializeComponent();
good luck!
Belee
"Pohihihi" wrote:

This one is really stupid Q but I am little not sure why my following
code
is doing nothing in load event of form.
this.StartPosition = FormStartPosition.CenterScreen

Rather starting form in center it just opens as default (and that is
where
ever)

any pointers?



Nov 17 '05 #6
because in the load event, the StartPosition has already been read and form
initialized, so changing the StartPosition in form load has no effect.

"Pohihihi" <po******@hotmail.com> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
my code is in Form load event. basically what I am doing is that loading
form state from registry. if there is no saved information then it will
default to center of the screen. It does work after Init function (as
Belee suggested) but i want it to function in load event. I can go for
location settings but StartPosition makes things way easy as I do not have
to worry about resolution/screen calculation on client machine.

adition to that what is the reason behind StartPosition not working in any
other place other than in ctor?

Thanks.

"Derrick" <de***********@hotmail.com> wrote in message
news:rM*******************@news20.bellglobal.com.. .
Where are you setting it "at runtime"? I would say that anywhere other
than the constructor would not work, since by that time the form has
already "started". You'd probably have to change forms Location
property, instead of StartPosition.

"Pohihihi" <po******@hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
Actually I should have said that it do work using properties but it do
not work if I try to set that at run time.
"Belee" <Be***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
This property can be set in the properties window. Note that, the
properties
you set in the properties window does not appear anywhere apart from
the
initialize components method which is called from the constructor.
With this
in mind, you have to put you code in the constructor after the
following line
of code:
InitializeComponent();
good luck!
Belee
"Pohihihi" wrote:

> This one is really stupid Q but I am little not sure why my following
> code
> is doing nothing in load event of form.
> this.StartPosition = FormStartPosition.CenterScreen
>
> Rather starting form in center it just opens as default (and that is
> where
> ever)
>
> any pointers?
>
>
>



Nov 17 '05 #7

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

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
0
by: Zabby | last post by:
hi... i draw a form dynamically with me.width=x me.height=y all works fine.... but before i display the form, i want to set it to centerscreen with: Me.StartPosition =...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
1
by: dr | last post by:
how to get the System.Drawing.Point of FormStartPosition, e.g. if i want to recenter the form on the screen at some point other then startup.
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: 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
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?
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,...

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.