J
Jimmy
Hey
A strange problem happens when i use show and hide. Form1 shows Form2 and
afterwards Form2 hides Form1. Form2 does stay in the foreground (before,
Form1 would stay in the foreground), but the title bar shows "Form1". When i
Close Form2, nothing happens. If i try to close it again i get an exception.
This makes sense, as i think that im actually closing Form1 at the first
click, wich puts Form2 in front. On the second click i try to show Form1
wich is disposed.
Now, isnt that strange?
This is a big problem for me!
I really hope you can help me. Why cant i hide Form1 properly?
Heres some code:
This is Form1:
private void dataGrid1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
try
{
DataGrid.HitTestInfo hitTestObj;
hitTestObj = dataGrid1.HitTest(e.X, e.Y);
if (hitTestObj.Type == DataGrid.HitTestType.RowHeader)
{
if ((int)dataGrid1[hitTestObj.Row,0] == 1)
MessageBox.Show("blablabla", "", MessageBoxButtons.OK,
MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
else
{
Form2 frm_2 = new Form2(this);
frm_2.Show();
}
}
}
catch (Exception f)
{
MessageBox.Show(f.ToString());
}
}
This is Form2:
private void Form2_Load(object sender, System.EventArgs e)
{
frm_1.Hide(); //This does hide Form1 but leaves the title bar with the
name of the Form1
}
private void frm_materialeDetail_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
frm_1.Show();
}
A strange problem happens when i use show and hide. Form1 shows Form2 and
afterwards Form2 hides Form1. Form2 does stay in the foreground (before,
Form1 would stay in the foreground), but the title bar shows "Form1". When i
Close Form2, nothing happens. If i try to close it again i get an exception.
This makes sense, as i think that im actually closing Form1 at the first
click, wich puts Form2 in front. On the second click i try to show Form1
wich is disposed.
Now, isnt that strange?
This is a big problem for me!
I really hope you can help me. Why cant i hide Form1 properly?
Heres some code:
This is Form1:
private void dataGrid1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
try
{
DataGrid.HitTestInfo hitTestObj;
hitTestObj = dataGrid1.HitTest(e.X, e.Y);
if (hitTestObj.Type == DataGrid.HitTestType.RowHeader)
{
if ((int)dataGrid1[hitTestObj.Row,0] == 1)
MessageBox.Show("blablabla", "", MessageBoxButtons.OK,
MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
else
{
Form2 frm_2 = new Form2(this);
frm_2.Show();
}
}
}
catch (Exception f)
{
MessageBox.Show(f.ToString());
}
}
This is Form2:
private void Form2_Load(object sender, System.EventArgs e)
{
frm_1.Hide(); //This does hide Form1 but leaves the title bar with the
name of the Form1
}
private void frm_materialeDetail_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
frm_1.Show();
}