Prashant Singh

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();

}

}




Re: .NET Compact Framework Unable to set focus on Form after using ShowDialog()

ChunSheng Tang - MSFT


Hi, Prashant

It could not be reproduced on Windows Mobile 6 Professional Emulator and .NET Compact Framework 2.0 sp2. The MainForm did get the focus. Show me your environment please.

Best Regards
Chunsheng Tang