Frazzle
Frazzle

Reputation: 157

ShowDialog() Not showing the form on top of the main form

I have a winforms application that handle's subscription data. The main form checks if the user is in the datastore(xml file) if not i call this. UserDetails is a data entry form.

else
{
    Form frm = new UserDetails();
    frm.ShowDialog();
}

The Problem is the UserDetail form is not on top and I can select the main form.

Upvotes: 6

Views: 8469

Answers (2)

ParsiVip
ParsiVip

Reputation: 11

Try to use one of the bellow solutions:

  1. try to use Show method with topmost property set to true:
frm.TopMost = true;
frm.Show(mainForm);
  1. try to use ShowDialog method:
frm.ShowDialog(mainForm);

using from one of the above solutions depends to your UI and logic.

Upvotes: 0

Rotem
Rotem

Reputation: 21917

This may happen if your main form is TopMost.

Try using

frm.ShowDialog(this);

when called from the main form.

This will ensure that the dialog is a visual child of the main form, and even if the main form is TopMost, the dialog will be above it.

Upvotes: 13

Related Questions