我现在做的是:
通过A窗口打开B窗口后,
通过A窗口的this.Visible=false;隐藏A窗口
当我关闭B窗口后,通过B窗口的A.Visible=true;来显示A窗口最后当我关闭A窗口后。
VS还是停留在调试阶段,没有恢复到调试前的状态。
请问各位前辈,这是正常还是不正常?
不正常是由什么原因引起的?请指点一下谢谢。
通过A窗口打开B窗口后,
通过A窗口的this.Visible=false;隐藏A窗口
当我关闭B窗口后,通过B窗口的A.Visible=true;来显示A窗口最后当我关闭A窗口后。
VS还是停留在调试阶段,没有恢复到调试前的状态。
请问各位前辈,这是正常还是不正常?
不正常是由什么原因引起的?请指点一下谢谢。
Private Sub AnnexLvw_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnnexLvw.DoubleClick
Dim b As New JvMPImg
Me.Visible = False
b.show()
If b.DialogResult = Windows.Forms.DialogResult.OK Then
Me.Visible = True
End If
End Sub
'B窗体的关闭事件
Private Sub JvMPartMag_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.DialogResult = Windows.Forms.DialogResult.OK
End Sub
我在B中,用的A a= new A();
a.Visible=true;
this.Close();,关闭B窗口
这应该不会有什么问题吧?如果是在A中响应B的关闭时间,代码应该怎么写啊?大哥
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Game
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
} //注册
private void btReg_Click(object sender, EventArgs e)
{ regForm rf = new regForm();
this.Visible = false;//打开注册窗体隐藏本窗体,也可以用this.Hide();
rf.Show();
}
子窗体
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Game
{
public partial class regForm : Form
{
public regForm()
{
InitializeComponent();
}
//关闭
private void btExit_Click(object sender, EventArgs e)
{
MainForm mf = new MainForm();
mf.Visible=true;
this.Close();
}
}
}
楼主在B里NEW A()有点问题,这样会有两个A
建议在B里构造函数,show b()时把A传过来,
这样就可以在B里操作A了,
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Game
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
} //注册
private void btReg_Click(object sender, EventArgs e)
{ regForm rf = new regForm();
this.FormClosed+=new FormClosedEventHandler(Form1_FormClosed);
this.Visible = false;//打开注册窗体隐藏本窗体,也可以用this.Hide();
rf.Show();
} void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
//关闭子窗体后就会执行到这里,显示主窗体
this.Show();
} }
}
子窗体
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Game
{
public partial class regForm : Form
{
public regForm()
{
InitializeComponent();
}
//关闭
private void btExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}你的程序主窗体其实没关闭还是隐藏的,因为你在子窗体中显示的是你重新建立的一个窗体,只是和主窗体是一样的。
而你却是新建了个主窗体,原本的主窗体并未显示
private void btExit_Click(object sender, EventArgs e)
{
MainForm mf = new MainForm();//这里你新建了
mf.Visible=true;
this.Close();
}
所以你关闭了窗体,程序却没退出