如何将值从子表单传递回父表单? [英] How do I pass a value from a child back to the parent form?

查看:28
本文介绍了如何将值从子表单传递回父表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将值从子表单传递回父表单?我有一个字符串要传回给父级.

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();

推荐答案

FormOptions 上创建一个属性(或方法),比如 GetMyResult:

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天全站免登陆