Okay, I have a WinForms C# program I am writing in Visual Studio 2010 Express. This program has two forms, the main form called “MainForm”, and a secondary form called “ConfigForm”. The MainForm has a button on it which pops up the ConfigForm.
private void buttonConfig_Click(object sender, EventArgs e)
{
new ConfigForm().Show();
}
Right now, when you click the button, the ConfigForm pops up wherever it feels like it. It doesn’t necessarily pop up over the MainForm. How do I get it to popup on top of the main form? I have tried setting ConfigForm’s StartPosition to CenterParent, but that doesn’t seem to do anything.
For that matter, how do I “lock” the program while the ConfigForm is open. When the ConfigForm is open, I would prefer if the user doesn’t have the ability to navigate back to the MainForm.
You are probably looking for something like this:
And yes, make sure that
ConfigForm.StartPosition = CenterParentas you noted.On the ConfigForm form, you can have your buttons set the
DialogResultsof the form, like this:Then your calling convention can be: