C#

我在form1中调用form2 ,form2中弹出提示对话框后 确定后 form2也消失了,返回到form1 我不想返回form1只是退出form2中的一个过程 在vb中用Exit Sub 在C#中用???
使用return后form2自动关闭,返回form1中调用form2的地方

解决方案 »

  1.   

    把你的代码发给我看一下,应该不会关闭form2呀
      

  2.   

    form1中调用form2 的代码
    private void button1_Click(object sender, System.EventArgs e)
    {
    form2 frm=new form2 ();
    frm.ShowDialog  ();
    DialogResult result=frm.DialogResult;
    if (result==DialogResult.OK   )
    {
    shuaxin();
    }
    form2中-----------------------------------------------------
    private void button1_Click(object sender, System.EventArgs e)
    {
    try
    {
    if (txtbh.Text!="" && txtlx.Text!="" && txtgg.Text!="" && comlx.Text!="")
    {
    // throw new Exception  ("请添加所有项目");

    }
    else
    {
    DialogResult result;
                result=MessageBox.Show (this, "必须填满所有字段值!" , "错误!",MessageBoxButtons.OK  ) ; 
    // this.Visible =false;
    // this.Close ();
    //         this.Show ();
    if (result==DialogResult.OK )
    {
    // return;
    }
    }
    }
    catch (Exception ed )
    {
    MessageBox.Show ( "保存数据记录发生 " + ed.ToString ( ) , "错误");
    }
          
    }
      

  3.   

    form2中-----------------------------------------------------
    private void button1_Click(object sender, System.EventArgs e)
    {
    this.Visible =false;《--这里应该设置为true,如果设置为false窗体就不可见了
    }