两个窗体需要由一个Windows窗体应用程序控制 [英] Two forms need to control by one windows form application

查看:80
本文介绍了两个窗体需要由一个Windows窗体应用程序控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个应用程序中有两个Windows窗体,例如Form1&表格2.我的问题是我无法使用Form2将文本框显示为真".请查看下面的代码,让我知道出了什么问题?在更正中

I have two windows forms in one application as Form1 & Form2. My problem is I couldn’t "visible true" a textbox using Form2. Please see below my code and let me know what is wrong? In the correction

In the correction I want to run a function/method in Form1 by button click in Form2, so I think it will work well.

Form1:
        internal void VisibleFalse()
        {
            textBox1.Visible = true;
        }

Form2:
        private void button1_Click(object sender, EventArgs e)
        {
            Form1 frm22 = new Form1();
            frm22.VisibleFalse();
        }

推荐答案

您正在访问类型为Form1的新实例,该实例从未显示过……我认为您需要将Form1的实例传递给Form2实例以实现您的目标!
you are accessing a new instance of type Form1, which never is shown...i think you need to pass an instance of Form1 to the instance of Form2 in order achieve your goal!


这篇关于两个窗体需要由一个Windows窗体应用程序控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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