Hi All,
I am creating an application that uses multiple forms.
The structure is like as under:
Main Form----> Child Form-1, Child Form-2, Child Form-n ----> Detail Form-1 , Detail Form-2 , Detail Form-n
Main form is the starting form.
It uses ListForm.Show() for opening Child Forms.
While Child forms use DetailForm.ShowDialog() to open Detail Forms.
When I switch from Detail form to Main Form (after setting DetailForm.DialogResult = DialogResult.Cancel) the focus is not set to the Main Form.
Attached is the snippet of the source code:
class MainForm : Form
{
private static MainForm _instance;
public static MainForm Instance
{
get
{
if (_instance == null)
_instance = new MainForm ();
return _instance;
}
}
private void showChildForm()
{
ChildForm.Instance.Show();
}
}
class ChildForm: Form
{
private static ChildForm_instance;
private bool value;
public static ChildFormInstance
{
get
{
if (_instance == null)
_instance = new ChildForm();
return _instance;
}
}
private void showDetailsForm()
{
DetailsForm form = new DetailsForm();
DialogResult result = form.ShowDialog();
if(result == DialogResult.OK)
value = true;
else
value = true;
}
}
class DetailForm: Form
{
private
void mnuSwitch_Click(object sender, EventArgs e) {this.DialogResult = DialogResult.Cancel;
MainForm.Instance.Show();
}
}