Call a form form a form

  • Thread starter Thread starter Dmitri Shvetsov
  • Start date Start date
D

Dmitri Shvetsov

Hi,

Can somebody give a quick advice?

I call a new form from a main form, like:

CNewForm nf = new CNewForm();

where I should insert a string into a TextBox.Text field. Then I should
return this string to a main form to the place from where I created and
called this child form. Everything's good, I create the child form, but the
main process goes ahead without any stop and I can't grab the string from
the child form to the main one using a public variable string or some other
way.

What's the easiest way to stop the main thread and wait until I enter a
required string and then press Enter on the child form to confirm or Cancel
to refuse? Do I need some trick to do that? The main process should wait
until it can get this string, then it should run ahead using this string.

How, to write a simple loop with a short delay and messages resolution in a
main class expecting while the child form receives Enter/Cancel? Then catch
the signal and leave this loop? It's not very good I think.

It should be much easier to use the same form for that but I decided to use
a separate one and I need some mechanism to synchronize both forms, to stop,
wait, etc. What happens when I create a new form and activate it? A separate
GUI thread starts or what?

Thanks,
Dmitri
 
If I understand you, you want to use

if(nf.ShowDialog() == DialogResult.Ok)
{
get various things from nf
}

Remember to set the enter key to return DialogResult.Ok
 
hi
Instead of opening the form nf.show(), open it as
nf.ShowDialog(); The main form waits until the nf object
closed. Its a Modal form as Dialog box,MessageBox etc.
 
Back
Top