1. <tfoot id='AjE3u'></tfoot>

  2. <i id='AjE3u'><tr id='AjE3u'><dt id='AjE3u'><q id='AjE3u'><span id='AjE3u'><b id='AjE3u'><form id='AjE3u'><ins id='AjE3u'></ins><ul id='AjE3u'></ul><sub id='AjE3u'></sub></form><legend id='AjE3u'></legend><bdo id='AjE3u'><pre id='AjE3u'><center id='AjE3u'></center></pre></bdo></b><th id='AjE3u'></th></span></q></dt></tr></i><div id='AjE3u'><tfoot id='AjE3u'></tfoot><dl id='AjE3u'><fieldset id='AjE3u'></fieldset></dl></div>
  3. <small id='AjE3u'></small><noframes id='AjE3u'>

      <bdo id='AjE3u'></bdo><ul id='AjE3u'></ul>
    <legend id='AjE3u'><style id='AjE3u'><dir id='AjE3u'><q id='AjE3u'></q></dir></style></legend>

    1. 将值从一个表单发送到另一个表单

      Send values from one form to another form(将值从一个表单发送到另一个表单)

          • <bdo id='tsvdV'></bdo><ul id='tsvdV'></ul>

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

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

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

                  <tbody id='tsvdV'></tbody>
              1. 本文介绍了将值从一个表单发送到另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想在两个表单 (c#) 之间传递值.我该怎么做?

                I want to pass values between two Forms (c#). How can I do it?

                我有两种表格:Form1 和 Form2.

                I have two forms: Form1 and Form2.

                Form1 包含一个按钮.当我单击该按钮时,Form2 应该打开并且 Form1 应该处于非活动模式(即不可选择).

                Form1 contains one button. When I click on that button, Form2 should open and Form1 should be in inactive mode (i.e not selectable).

                Form2 包含一个文本框和一个提交按钮.当我在 Form2 的文本框中键入任何消息并单击提交按钮时,Form2 应该关闭并且 Form1 应该突出显示提交的值.

                Form2 contains one text box and one submit button. When I type any message in Form2's text box and click the submit button, the Form2 should close and Form1 should highlight with the submitted value.

                我该怎么做?有人可以通过一个简单的示例帮助我做到这一点.

                How can i do it? Can somebody help me to do this with a simple example.

                推荐答案

                有几种解决方案,但这是我倾向于使用的模式.

                There are several solutions to this but this is the pattern I tend to use.

                // Form 1
                // inside the button click event
                using(Form2 form2 = new Form2()) 
                {
                    if(form2.ShowDialog() == DialogResult.OK) 
                    {
                        someControlOnForm1.Text = form2.TheValue;
                    }
                }
                

                还有……

                // Inside Form2
                // Create a public property to serve the value
                public string TheValue 
                {
                    get { return someTextBoxOnForm2.Text; }
                }
                

                这篇关于将值从一个表单发送到另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 列表框上的取消选择)

                <tfoot id='9JNnI'></tfoot>
                <legend id='9JNnI'><style id='9JNnI'><dir id='9JNnI'><q id='9JNnI'></q></dir></style></legend>

                  <bdo id='9JNnI'></bdo><ul id='9JNnI'></ul>

                    <small id='9JNnI'></small><noframes id='9JNnI'>

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