关闭当前表单并打开该表单的新表单 [英] Close current form and open new one of that form closed

查看:339
本文介绍了关闭当前表单并打开该表单的新表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表单在表单1我有一个按钮当我点击按钮表单2将显示和我的数据显示在表单2到目前为止它确定但我希望当其中一个表单2打开如果用户点击在表单1中按钮然后关闭此表单2并打开一个新表单!不要打开其他表格2我希望你理解我的问题:D对不起英语不好



i have 2 form in form 1 i have a button when i click on button form 2 will be show and my data are showing on form 2 so far its OK but i want when one of form 2 its open if user click on button in form 1 then close this form 2 and open a new one! not open an other form 2 i hope u understand my question :D sorry for bad English

and here is button code :

    private void btnSave_Click(object sender, EventArgs e)
    {

            if (RadioMale.Checked == true)
            {
                jensiyat = "مرد";
            }
            else { jensiyat = "زن"; }
            if (RadioMarried.Checked == true)
                tahol = "متاهل";
            else tahol = "مجرد";
        Class1.txt +=
           "________________________\n\n" + "مشخصات مربوط به  خانم/آقای " 
           + tbFamily.Text + "\n________________________" +
            "\nنام و نام خانوادگی: " + tbName.Text + " " +
            tbFamily.Text + "\n" + "ایمیل: " + tbEmail.Text + "\n" + "شماره ملی: " +
            tbCodmeli.Text + "\n" + "سریال شناسنامه: " +
            tbSerialShenasname.Text
            + "\nشهر محل زندگی: "+ shahr + " - " + TreeShahr.SelectedNode.Text
            + "\nآدرس: " + tbAddress.Text + "\n"
            + " تحصیلات : " + ComboTahsilat.SelectedItem
            + "\nجنسیت : " +jensiyat
            + "\nوضعیت تاهل: " + tahol
            + "\nتاریخ تولد: " + BirthTimePicker.Value.ToPeString()
            + "\n__________________________________________________";

        Form frm2 = new Form2();
        frm2.Show();
    }





我的尝试:



i尝试了表单实例函数,但它没有工作它只是保持这个表单2并且不允许打开新表单!使用这些代码:





What I have tried:

i tried form instance function but its not working its just hold this form 2 and will not allow to open new one! with these code:

public static Form2 Instance
   {
       get
       {
           if (_form2 == null)
           {
               _form2 = new Form2();
           }
           return _form2;

       }
   }

推荐答案

我建​​议你看一下应用程序.OpenForms-Collection如果Form2已经打开。
I would suggest you look inside the Application.OpenForms-Collection if the Form2 is allready opened.


这篇关于关闭当前表单并打开该表单的新表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆