469,643 Members | 1,531 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

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 16862
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
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.