473,509 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(Simple?) code has me beat - Help ?

I want to write some code to center one form over another (show one form
on top of the other). Anyone care to show me in a few lines how to do
this ?. Thanks

Nov 24 '05 #1
3 1260
why not set both the size and locations equal?

Gabriel

"Ann Huxtable" <an**********@research-labs.de> wrote in message
news:dm**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
I want to write some code to center one form over another (show one form on
top of the other). Anyone care to show me in a few lines how to do this ?.
Thanks

Nov 24 '05 #2
If you're showing the form using the ShowDialog method then set the form's
StartPosition to FormStartPosition.CenterParent. Otherwise, you can use code
similar to the code shown below.

Form2 f = new Form2();
f.StartPosition = FormStartPosition.Manual;
f.Location = new Point((this.Left + (this.Width / 2) - (f.Width / 2)),
(this.Top + (this.Height / 2) - (f.Height / 2)));
f.Show();

--
Tim Wilson
..NET Compact Framework MVP

"Ann Huxtable" <an**********@research-labs.de> wrote in message
news:dm**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
I want to write some code to center one form over another (show one form
on top of the other). Anyone care to show me in a few lines how to do
this ?. Thanks

Nov 24 '05 #3


Tim Wilson wrote:
If you're showing the form using the ShowDialog method then set the form's
StartPosition to FormStartPosition.CenterParent. Otherwise, you can use code
similar to the code shown below.

Form2 f = new Form2();
f.StartPosition = FormStartPosition.Manual;
f.Location = new Point((this.Left + (this.Width / 2) - (f.Width / 2)),
(this.Top + (this.Height / 2) - (f.Height / 2)));
f.Show();


Thanks Tim - that's exactly what I needed!

Nov 25 '05 #4

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

Similar topics

11
2676
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
41
7470
by: Seth | last post by:
I am in need of source code for the Aho Corasick algorithm. I have tried searching the web but can't seem to find any code. Is there a good site for c code I can search? Thanks in advance.
176
8186
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
30
3472
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
4
1581
by: rstrathdee | last post by:
What sites do you recommend for me to learn how to construct good, simple templates for php/mysql (using css?)
0
7137
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
7347
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,...
1
7073
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...
0
7506
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...
1
5062
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...
0
4732
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...
0
3218
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.