我怎样才能将值从一种形式到另一个? [英] How can I pass values from one form to another?

查看:96
本文介绍了我怎样才能将值从一种形式到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑在那里我有两个窗口形式的情况下,说 F1 F2 。使用 F1 之后,我现在已经叫 F2.ShowDialog()。这使得 F2 在屏幕上也是如此。现在,这两种形式是可见的,我怎么能传递从 F1 F2 数据?此外,一旦 F2 (A模态对话框)结束后,我怎么能返回数据 F1

Consider the situation where I have two windows forms, say F1 and F2. After using F1, I have now called F2.ShowDialog(). This puts F2 on the screen as well. Now that both forms are visible, how can I pass data from F1 to F2? Additionally, once F2 (A modal dialog) finishes, how can I return data to F1?

推荐答案

有没有人认为仅仅是值传递给形式标记属性。

Has anyone considered simply passing the value to the form in the tag attribute.

Form newForm = new form();
newForm.Tag = passValue;
newform.showmodal();

当newform示出了负载(或任何其他)例程可以在标签使用数据

when newform is shown the load (or any other) routine can use the data in tag

public void load()
{
  if (this.Tag.length > 0)
  {
     // do something with the data
  }
}

这篇关于我怎样才能将值从一种形式到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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