• <small id='s1o5x'></small><noframes id='s1o5x'>

    <i id='s1o5x'><tr id='s1o5x'><dt id='s1o5x'><q id='s1o5x'><span id='s1o5x'><b id='s1o5x'><form id='s1o5x'><ins id='s1o5x'></ins><ul id='s1o5x'></ul><sub id='s1o5x'></sub></form><legend id='s1o5x'></legend><bdo id='s1o5x'><pre id='s1o5x'><center id='s1o5x'></center></pre></bdo></b><th id='s1o5x'></th></span></q></dt></tr></i><div id='s1o5x'><tfoot id='s1o5x'></tfoot><dl id='s1o5x'><fieldset id='s1o5x'></fieldset></dl></div>
    <tfoot id='s1o5x'></tfoot>

        <bdo id='s1o5x'></bdo><ul id='s1o5x'></ul>

        <legend id='s1o5x'><style id='s1o5x'><dir id='s1o5x'><q id='s1o5x'></q></dir></style></legend>
      1. 返回上一个表单(c#)

        go back to the previous form (c#)(返回上一个表单(c#))
        • <bdo id='AOoSP'></bdo><ul id='AOoSP'></ul>
            <tbody id='AOoSP'></tbody>

          1. <i id='AOoSP'><tr id='AOoSP'><dt id='AOoSP'><q id='AOoSP'><span id='AOoSP'><b id='AOoSP'><form id='AOoSP'><ins id='AOoSP'></ins><ul id='AOoSP'></ul><sub id='AOoSP'></sub></form><legend id='AOoSP'></legend><bdo id='AOoSP'><pre id='AOoSP'><center id='AOoSP'></center></pre></bdo></b><th id='AOoSP'></th></span></q></dt></tr></i><div id='AOoSP'><tfoot id='AOoSP'></tfoot><dl id='AOoSP'><fieldset id='AOoSP'></fieldset></dl></div>

              <legend id='AOoSP'><style id='AOoSP'><dir id='AOoSP'><q id='AOoSP'></q></dir></style></legend>
                <tfoot id='AOoSP'></tfoot>

                1. <small id='AOoSP'></small><noframes id='AOoSP'>

                  本文介绍了返回上一个表单(c#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道如何在模态模式下转到另一个表单,就像我在下面所做的那样:

                  I know how to go to another form in modal mode just like what I did below:

                  public partial class Form1 : Form
                  {
                      public Form1()
                      {
                          InitializeComponent();
                      }
                  
                      Form2 myNewForm = new Form2();
                      private void button1_Click(object sender, EventArgs e)
                      {
                          this.Hide();
                          myNewForm.ShowDialog();
                  
                  
                      }
                  }
                  

                  这是我的第二个表格,我该如何回到之前的表格?

                  This is my second form, how do I go back to the previous form?

                  public partial class Form2 : Form
                  {
                      public Form2()
                      {
                          InitializeComponent();
                      }
                  
                      private void Form2_Load(object sender, EventArgs e)
                      {
                  
                      }
                      private void button1_Click(object sender, EventArgs e)
                      {
                          this.Hide();
                          // what should i put here to show form1 again
                      }
                  
                  }
                  

                  推荐答案

                  当你在表单上调用 ShowDialog 时,它会一直运行,直到表单关闭,表单的 DialogResult属性设置为 None 以外的值,或者单击具有 DialogResult 属性而不是 None 的子按钮.所以你可以做类似的事情

                  When you call ShowDialog on a form, it runs until the form is closed, the form's DialogResult property is set to something other than None, or a child button with a DialogResult property other than None is clicked. So you could do something like

                  public partial class Form1
                  {
                      ...
                      private void button1_Click(object sender, EventArgs e)
                      {
                          this.Hide();
                          newform.ShowDialog();
                          // We get here when newform's DialogResult gets set
                          this.Show();
                      }
                  }
                  
                  public partial class Form2
                  {
                      ...
                      private void button1_Click(object sender, EventArgs e)
                      {
                          // This hides the form, and causes ShowDialog() to return in your Form1
                          this.DialogResult = DialogResult.OK;
                      }
                  }
                  

                  虽然如果您在单击按钮时除了从表单返回之外什么都不做,您可以在表单设计器中设置 Form2.button1 上的 DialogResult 属性,而您不会根本需要 Form2 中的事件处理程序.

                  Although if you're not doing anything but returning from the form when you click the button, you could just set the DialogResult property on Form2.button1 in the form designer, and you wouldn't need an event handler in Form2 at all.

                  这篇关于返回上一个表单(c#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                  <legend id='ksYcW'><style id='ksYcW'><dir id='ksYcW'><q id='ksYcW'></q></dir></style></legend>
                  <tfoot id='ksYcW'></tfoot>

                  <small id='ksYcW'></small><noframes id='ksYcW'>

                      <tbody id='ksYcW'></tbody>
                    <i id='ksYcW'><tr id='ksYcW'><dt id='ksYcW'><q id='ksYcW'><span id='ksYcW'><b id='ksYcW'><form id='ksYcW'><ins id='ksYcW'></ins><ul id='ksYcW'></ul><sub id='ksYcW'></sub></form><legend id='ksYcW'></legend><bdo id='ksYcW'><pre id='ksYcW'><center id='ksYcW'></center></pre></bdo></b><th id='ksYcW'></th></span></q></dt></tr></i><div id='ksYcW'><tfoot id='ksYcW'></tfoot><dl id='ksYcW'><fieldset id='ksYcW'></fieldset></dl></div>
                          • <bdo id='ksYcW'></bdo><ul id='ksYcW'></ul>