Opening a dialog box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have three forms.

The first is opened when the application starts. It has a New option that when selected creates a second form a calls ShowDialog() on that form.

The dialog form (when filled in) creates a third form and then shows it (using Show()), before calling close() on itself.

The problem is that instead of the focus being set on the form created by the dialog, it reverts back to the first form.

If I don't call close on the dialog, the focus is correct. Also, if I show the second form using just Show() instead of ShowDialog(), when the close() is called the third form is correctly focused.

Is there some issue I haven't considered when using ShowDialog()?
 
Pete said:
I have three forms.

The first is opened when the application starts. It has a New option
that when selected creates a second form a calls ShowDialog() on that
form.

The dialog form (when filled in) creates a third form and then shows
it (using Show()), before calling close() on itself.

The problem is that instead of the focus being set on the form
created by the dialog, it reverts back to the first form.

I think that if you set the owner of Form2 and 3 to be Form1 and call
Focus() or Select() on Form3 before closing Form2 it should work fine.
Actually, calling Focus() on Form3 alone without setting the owner of the
form may work as well. I've not tried it though.
 
Back
Top