在子表单上使用来自父表单的变量? [英] Using variables from a parent form on child form?

查看:18
本文介绍了在子表单上使用来自父表单的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击我制作的表单上的退出按钮会弹出另一个表单,该表单应该包含赢和输的值.

Clicking an exit button on a form I made pops up another form, which is supposed to house the values of Wins and Losses.

如何在弹出的表单中使用主表单中的变量?我是一个非常新的程序员.

How can I use the variable from the main form in the form that pops up? I'm very new programmer.

推荐答案

//in child form...    
class Form_pop
{
    public Form_pop(int wins, int loses)
    {
        this.wins = wins;
        this.loses = loses;
    }

    int wins;
    int loses;

    private void Form_pop_Load(object sender, EventArgs e)
    {
        Label_wins.Text = wins.ToString();
        Label_loses.Text = loses.ToString();
    }
}

//In parent form...
Form_pop form_pop = new Form_pop(yourWins, yourLoses);
form_pop.show();

这篇关于在子表单上使用来自父表单的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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