centering a childform in MDI parent

P

Peted

I have a simple c# app that opens a child form in a mdi parent.

I want the child form to open in the center of the mdi parent, so i
can open the child form ok, it all works fine, but setting

frmConfig = new ConfigForm(this);
frmConfig.MdiParent = this;
frmConfig.TopLevel = false;

frmConfig.StartPosition = FormStartPosition.CenterParent;
frmConfig.Show();


does not seem to work regardless if i set it runtime or in the windows
properties at design time.

The only way i can get CenterParent to work is to display the form
using Showdialog(), but then it has to be top level and the user can
drag it out the bounds of the MDI parent.


What i have found is if i use

frmConfig.StartPosition = FormStartPosition.CenterScreen;


this will display the childform in the center of the parent, seemingly
regardless of where the parent is located on screen.


All the internet examples ive found say to use
FormStartPosition.CenterParent;

Does anyone have any idea whats going on and how it should be done ?


Peted
 
A

andy

I will try it
if you can save your some time,pls help me solvet my problem:
===
how to know some fields were modified by user?
dear all,
how to know some fields were modified by user?
list bellow my project:
components: DataGridView,DataSet
when user change the DataGridView colmons field value,we can use
Dataset.Getchanges.tables[0] to list current record was modified.
but I can't know which fields were edited,only know the user edit the row.
even though I can't know it if a new record or edited record.
thanks all!!!
andy
2007-08-23

===
 
G

Guest

Hi,
I also have faced same problem long back...
I am just giving you hint ... not a solution

Put frmConfig.StartPosition = FormStartPosition.CenterParent;
statement immidetely after frmConfig = new ConfigForm(this);

and put CenterParent in design time also.

Kishor
 
G

Guest

Hey andy.....

There are many thirdparty components are available.... check for dirtybit
cheker.


Regards,
Kishor






andy said:
I will try it
if you can save your some time,pls help me solvet my problem:
===
how to know some fields were modified by user?
dear all,
how to know some fields were modified by user?
list bellow my project:
components: DataGridView,DataSet
when user change the DataGridView colmons field value,we can use
Dataset.Getchanges.tables[0] to list current record was modified.
but I can't know which fields were edited,only know the user edit the row.
even though I can't know it if a new record or edited record.
thanks all!!!
andy
2007-08-23

===
I have a simple c# app that opens a child form in a mdi parent.

I want the child form to open in the center of the mdi parent, so i
can open the child form ok, it all works fine, but setting

frmConfig = new ConfigForm(this);
frmConfig.MdiParent = this;
frmConfig.TopLevel = false;

frmConfig.StartPosition = FormStartPosition.CenterParent;
frmConfig.Show();


does not seem to work regardless if i set it runtime or in the windows
properties at design time.

The only way i can get CenterParent to work is to display the form
using Showdialog(), but then it has to be top level and the user can
drag it out the bounds of the MDI parent.


What i have found is if i use

frmConfig.StartPosition = FormStartPosition.CenterScreen;


this will display the childform in the center of the parent, seemingly
regardless of where the parent is located on screen.


All the internet examples ive found say to use
FormStartPosition.CenterParent;

Does anyone have any idea whats going on and how it should be done ?


Peted
 
P

Peted

Hi Sorry but that does not make any difference.

Placing the statements in a different order makes no change, it still
cause the child form to appear upper to the left

the only thing that works is to use

FormStartPosition.CenterScreen; to center in a mdi form

is this normal ?

does any one know why this is please ?

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top