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

Why Can't I Preset Location of Modal Form?

In my WinForms application, I have a main form, which may or may not be
visible depending on the user's wishes. This main form initiates a separate
thread that starts a data transfer process.

In this thread I want to show a special dialog box. Because the question
must be answered, I'm using ShowDialog to display it. Just before doing so,
I have some simple code to:
- Center it in the main form, if that form is visible
- Center it in the screen otherwise

Yet to my amazement, this centering code (ie. Left & Top) has absolutely no
effect. Why not?

I even hardcoded in a new location but it had no effect either. Here's the
code in question:

frmInstallPrompt frmInstall = new frmInstallPrompt();
frmInstall.DisplayMobileDeviceInfo();
//frmInstall.CenterForm(parentForm, parentForm.WindowState);
frmInstall.Location = new System.Drawing.Point(1000, 1000);
DialogResult retval = frmInstall.ShowDialog();

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
2 6142
Have you tried:

frmInstall.StartPosition = FormStartPosition.CenterParent;
frmInstall.ShowDialog();

Regards - Octavio

"Robert W." <Ro*****@discussions.microsoft.com> escribió en el mensaje
news:71**********************************@microsof t.com...
In my WinForms application, I have a main form, which may or may not be
visible depending on the user's wishes. This main form initiates a
separate
thread that starts a data transfer process.

In this thread I want to show a special dialog box. Because the question
must be answered, I'm using ShowDialog to display it. Just before doing
so,
I have some simple code to:
- Center it in the main form, if that form is visible
- Center it in the screen otherwise

Yet to my amazement, this centering code (ie. Left & Top) has absolutely
no
effect. Why not?

I even hardcoded in a new location but it had no effect either. Here's
the
code in question:

frmInstallPrompt frmInstall = new frmInstallPrompt();
frmInstall.DisplayMobileDeviceInfo();
//frmInstall.CenterForm(parentForm, parentForm.WindowState);
frmInstall.Location = new System.Drawing.Point(1000, 1000);
DialogResult retval = frmInstall.ShowDialog();

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #2
Octavio,

Can I say Muchas Gracias?!

Coming from the VB6 world, I wasn't aware of the "FormStartPosition" property.

In point of fact, the "CenterParent" enum doesn't work because the parent
form is a notification window, not the main form I was referring to. But I
discovered another enum called "Manual". When set to this, it then does take
its location information from the Left & Top properties.

Thank you so much for clueing me in!

--
Robert W.
Vancouver, BC
www.mwtech.com

"Octavio Hernandez" wrote:
Have you tried:

frmInstall.StartPosition = FormStartPosition.CenterParent;
frmInstall.ShowDialog();

Regards - Octavio

"Robert W." <Ro*****@discussions.microsoft.com> escribió en el mensaje
news:71**********************************@microsof t.com...
In my WinForms application, I have a main form, which may or may not be
visible depending on the user's wishes. This main form initiates a
separate
thread that starts a data transfer process.

In this thread I want to show a special dialog box. Because the question
must be answered, I'm using ShowDialog to display it. Just before doing
so,
I have some simple code to:
- Center it in the main form, if that form is visible
- Center it in the screen otherwise

Yet to my amazement, this centering code (ie. Left & Top) has absolutely
no
effect. Why not?

I even hardcoded in a new location but it had no effect either. Here's
the
code in question:

frmInstallPrompt frmInstall = new frmInstallPrompt();
frmInstall.DisplayMobileDeviceInfo();
//frmInstall.CenterForm(parentForm, parentForm.WindowState);
frmInstall.Location = new System.Drawing.Point(1000, 1000);
DialogResult retval = frmInstall.ShowDialog();

--
Robert W.
Vancouver, BC
www.mwtech.com


Nov 17 '05 #3

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

Similar topics

4
by: Kyralessa | last post by:
In Access 2000, I have a base form with a ListBox of conference registrants. In the form's declarations section I include Dim f as Form To add a registrant I'm doing this: Set f = New...
5
by: will eichert | last post by:
Greetings. I have a problem with a combo box incorrectly displaying blank items when returning to a form from a modal form. It's fine when the main form first comes up, but gets messed up when the...
2
by: D Cameron | last post by:
I'd like to be able to make a full screen form in one of my apps inescapable: disable the Start button, Alt-Tab etc. until my application closes the form. I seem to remember VB3.0 distinguishing...
4
by: Brian Henry | last post by:
Hi, is there a way to get a form to post back to a modal dialog box when it was posted from a modal dialog to start with? here is the problem... I have a form with combo boxes and when you select...
3
by: Sarika | last post by:
I have some questions regarding Modal forms and would appreciate if someone could clarify my understanding. (a) I observed that the modal form's Form_Closing event is generated if I set the...
23
by: Chukkalove | last post by:
Im sorry, I dont know the correct description for a hierarchy of parent and child forms. I have a main form that opens a child form modally. This child form in turn opens it's own child form...
2
by: Mike | last post by:
Hi, I'm having a problem with modal forms on windows. I've written a very short test program, with a main window and a form called from the main window. The form is set to modal with...
1
by: samentu | last post by:
Hi there. I'm having a little problem here with some forms. Let me describe the problem: my application has a MDI parent form (the form that starts with the application); then when I click a button...
4
by: Johnny Jörgensen | last post by:
In my current project I've got some DataGridViews containing multiple hidden columns. For some reason 8 of the 10 grids I've got on my form has suddenly started showing 1 of the hidden columns...
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...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.