Hi,
Sorry that I may not understand your scenario exactly.
I performed a test on this issue. I create a WinForm application project
and add three forms(Form1, Form2, and Form3) in the project. I set the
IsMdiContainer property of Form1 to True. Add a Button on Form1 and a
DataGridView on Form2.
Add the following code in the Form1's Load event handler:
private void Form1_Load(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.MdiParent = this;
frm.Show();
}
Add the following code in the Click event handler of the button on Form1:
private void button1_Click(object sender, EventArgs e)
{
Form3 frm = new Form3();
frm.MdiParent = this;
frm.Show();
}
In Form2, add the following code:
public Form2()
{
InitializeComponent();
this.dataGridView1.CellValidating += new
DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);
}
void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
e.Cancel = true;
}
Build the project and run it. Form2 is shown as an MDI child with a
DataGridView in it. I click a cell within the DataGridView and then can not
move the focus out of the cell, because I have set the Cancel property of
the DataGridViewCellValidatingEventArgs parameter to true in the
DataGridView's CellValidating event handler.
At this time, I could still click the button on the MDI parent, but without
effect, i.e. Form3 isn't opened after I click the button.
However, If I use the MDIParent to create a new instance if the child
form, the focus remains on the error cell in the first form even with the
new form in the foreground.
Could you please tell me how the new form is created and shown?
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.