我如何通过从一个孩子的值回父窗体? [英] How do I pass a value from a child back to the parent form?

查看:131
本文介绍了我如何通过从一个孩子的值回父窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何通过一个数值从孩子回父窗体?我有一个,我想传递回父字符串。

我推出了采用子:

  FormOptions formOptions =新FormOptions();
formOptions.ShowDialog();
 

解决方案

创建于 FormOptions 属性(或方法),说 GetMyResult

 使用(FormOptions formOptions =新FormOptions())
{
    formOptions.ShowDialog();

    字符串结果= formOptions.GetMyResult;

    //做什么都与结果...
}
 

How do I pass a value from a child back to the parent form? I have a string that I would like to pass back to the parent.

I launched the child using:

FormOptions formOptions = new FormOptions();
formOptions.ShowDialog();

解决方案

Create a property (or method) on FormOptions, say GetMyResult:

using (FormOptions formOptions = new FormOptions())
{
    formOptions.ShowDialog();

    string result = formOptions.GetMyResult;

    // do what ever with result...
}

这篇关于我如何通过从一个孩子的值回父窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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