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

Center form on parent form

I have an application with a main form (size 300, 200) and I added another
form to the project. I would like to set the second form to center on the
main form. I have tried setting the parent of the second form to be the
first form using:

this.Parent = Form1; (both with and without the ( ))

but that doesn't work, otherwise I could set the CentreParent property for
Form2. I also tried adding the following to the constructor of Form1:

Form2 fm2 = new Form2();
fm2.Parent = this;

Still won't work.

Any ideas?
Nov 16 '05 #1
2 9519
Overload the form Layout evnt, and implement the proper logic to center to
one another form.

Good Luck.

"cashdeskmac" <ca*********@discussions.microsoft.com> wrote in message
news:84**********************************@microsof t.com...
I have an application with a main form (size 300, 200) and I added another
form to the project. I would like to set the second form to center on the
main form. I have tried setting the parent of the second form to be the
first form using:

this.Parent = Form1; (both with and without the ( ))

but that doesn't work, otherwise I could set the CentreParent property for
Form2. I also tried adding the following to the constructor of Form1:

Form2 fm2 = new Form2();
fm2.Parent = this;

Still won't work.

Any ideas?

Nov 16 '05 #2
Do you mean that CenterParent didn't work?

- Rakesh Rajan

"cashdeskmac" <ca*********@discussions.microsoft.com> wrote in message
news:84**********************************@microsof t.com...
I have an application with a main form (size 300, 200) and I added another
form to the project. I would like to set the second form to center on the
main form. I have tried setting the parent of the second form to be the
first form using:

this.Parent = Form1; (both with and without the ( ))

but that doesn't work, otherwise I could set the CentreParent property for
Form2. I also tried adding the following to the constructor of Form1:

Form2 fm2 = new Form2();
fm2.Parent = this;

Still won't work.

Any ideas?

Nov 16 '05 #3

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

Similar topics

4
by: Viken Karaguesian | last post by:
Hello all, I'm trying to create a Div style for a website that I'm playing around with. I'd like the DIV itsself to be center-aligned, but the text within the div to be left-aligned. My div...
1
by: David N | last post by:
Hi All, I have a text object that displays a string of text on a form object. The text string is displayed centerred in the parent form. How do I center the text if the parent form object is...
2
by: Alexander | last post by:
Hi, I have a simple Problem. I want to center a dialog on a panel of an application. I do the following: public class MyDialog : System.Windows.Forms.Form { private Panel m_ParentPanel; ...
2
by: SL33PY | last post by:
Hi and thank you for taking the time to read about my problem. I have a simple MDI parent form frmMain with a menu (file, edit, window, help). Under file you can create new childforms called...
1
by: Gernot Frisch | last post by:
I want to center the div "KungFu" over the div "header". Does not. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//DE"> <html> <body> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p>
5
by: vul | last post by:
I have an MDI application with a ListBar on the left side of MDI form. All child forms are displayed inside of the client area of MDI form. Now I need to display a third form from a child and...
2
by: Que | last post by:
Hi I have a form that catches an exception and throws a Messagebox Is it possible to throw the message box to center in the form that throws the exception Like Centre in parent form or...
2
by: rowe_newsgroups | last post by:
Hello all, I have something I believe is something simple, but I can't seem to figure out what to do. I did some searching, but I either can't get my search right. Anyways, on a new webpage I'm...
13
by: Stevo | last post by:
I've found that for IE6+, if you add the property text-align:center to a DIV, then *anything* inside it gets centered. That can be a table, an object/embed, another DIV, an image, or some text. ...
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:
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
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.