472,119 Members | 978 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Wait for user response on opened form

I am writing a program that has a portion which downloads files into a
selected directory. It first checks to see if the file exists if the
file exists it opens another form with buttons related to
overwriting, renaming etc. What is the proper way in windows forms
programming to open a new form and wait for the reponse of the form.
Currently I open it with form.show(); form.focus(); In the form I have
a variable set based on the user's input and I would like the program
to halt until there is a response. Related to this I would like the
new form to have focus and maintain focus. i.e. I don't want the
user to be able to navigate back to the mainform and have access to
that functionality. Your help is greatly appreciated.

Nov 16 '05 #1
3 16974
HooHa wrote:
I am writing a program that has a portion which downloads files into a
selected directory. It first checks to see if the file exists if the
file exists it opens another form with buttons related to
overwriting, renaming etc. What is the proper way in windows forms
programming to open a new form and wait for the reponse of the form.
Currently I open it with form.show(); form.focus(); In the form I have
a variable set based on the user's input and I would like the program
to halt until there is a response. Related to this I would like the
new form to have focus and maintain focus. i.e. I don't want the
user to be able to navigate back to the mainform and have access to
that functionality. Your help is greatly appreciated.


Try form.ShowDialog();
--
to reply, remove .s.p.a.m. from email
Nov 16 '05 #2
Open the second form as a modal dialog. When calling the form from within
your first form:

form2.ShowDialog(this); // this - your first form - is the owner of
the modal dialog

Form 2 will behave lilke a modal dialog now (such as the OpenFileDialog and
similar classes) and any code after the ShowDialog() method is not executed
until the modal dialog is closed.

Hope that helps.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"HooHa" <js*****@cox-dot-net.no-spam.invalid> wrote in message
news:41********@Usenet.com...
I am writing a program that has a portion which downloads files into a
selected directory. It first checks to see if the file exists if the
file exists it opens another form with buttons related to
overwriting, renaming etc. What is the proper way in windows forms
programming to open a new form and wait for the reponse of the form.
Currently I open it with form.show(); form.focus(); In the form I have
a variable set based on the user's input and I would like the program
to halt until there is a response. Related to this I would like the
new form to have focus and maintain focus. i.e. I don't want the
user to be able to navigate back to the mainform and have access to
that functionality. Your help is greatly appreciated.

Nov 16 '05 #3
Thank you both for your answers! That is exactly what I needed.

Cheers

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by dave | last post: by
4 posts views Thread by puja patel | last post: by
reply views Thread by Gentian Hila | last post: by

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.