C
ChrisM
I posted this last week, so apologies for re-posting but I'm still looking
for a sensible answer, and I'm hoping somone new might be able to cast some
light...
Basically, I have a fairly complicated application which seems to me to be
misbehaving. The following is an attempt to reproduce the error. There are
reasons in the real application why I'm trying to do things the way they are
here, so please no comments on techniques here, UNLESS I'm trying to do
somthing fundamentally wrong (or stupid!)
Anyway, if someone could humour me and try the following:
1) Create a new dotNET project.
2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the form
that should load on application startup).
3) Make frmMainForm an MDI Container Form.
4) Add the following code for MainForm:
private void MainForm_Load(object sender, System.EventArgs e)
{
frmForm1 form1 = new frmForm1();
form1.MdiParent = this;
form1.Show();
}
internal void ShowOtherForm()
{
frmForm2 form2 = new frmForm2();
form2.MdiParent = this;
form2.Show();
}
5) Place a button on form1 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
((frmMainForm)this.MdiParent).ShowOtherForm();
}
6) Place a button and a textBox on form2 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button Pressed");
this.SendToBack();
}
private void textBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("Enter Pressed");
}
7) Run the program, you should get as a child form inside MainForm
8) Click the button on form1 and you should get an instance of form2.
9) Click the button on form2 and you should get the 'Button Pressed' message
and Form1 comes to the front.
10) CLOSE Form1
11) Make sure focus is in the textBox on Form2 and press ENTER.
12) Please can someone explain what happens next...?
I would really appreciate it if someone could try this out and give me their
thoughts, because it's driving me crazy. I have this project available as a
zip-file if you can't be bothered with all the typing.
Many, many thanks.
ChrisM
for a sensible answer, and I'm hoping somone new might be able to cast some
light...
Basically, I have a fairly complicated application which seems to me to be
misbehaving. The following is an attempt to reproduce the error. There are
reasons in the real application why I'm trying to do things the way they are
here, so please no comments on techniques here, UNLESS I'm trying to do
somthing fundamentally wrong (or stupid!)
Anyway, if someone could humour me and try the following:
1) Create a new dotNET project.
2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the form
that should load on application startup).
3) Make frmMainForm an MDI Container Form.
4) Add the following code for MainForm:
private void MainForm_Load(object sender, System.EventArgs e)
{
frmForm1 form1 = new frmForm1();
form1.MdiParent = this;
form1.Show();
}
internal void ShowOtherForm()
{
frmForm2 form2 = new frmForm2();
form2.MdiParent = this;
form2.Show();
}
5) Place a button on form1 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
((frmMainForm)this.MdiParent).ShowOtherForm();
}
6) Place a button and a textBox on form2 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button Pressed");
this.SendToBack();
}
private void textBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("Enter Pressed");
}
7) Run the program, you should get as a child form inside MainForm
8) Click the button on form1 and you should get an instance of form2.
9) Click the button on form2 and you should get the 'Button Pressed' message
and Form1 comes to the front.
10) CLOSE Form1
11) Make sure focus is in the textBox on Form2 and press ENTER.
12) Please can someone explain what happens next...?
I would really appreciate it if someone could try this out and give me their
thoughts, because it's driving me crazy. I have this project available as a
zip-file if you can't be bothered with all the typing.
Many, many thanks.
ChrisM