从另一个表单访问 Button 属性 [英] Accessing Button properties from another form

查看:31
本文介绍了从另一个表单访问 Button 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个很常见的问题,我的问题是我尝试了几种方法,但没有一种对我有用.

I know this is a very common question, my problem is i have tried several methods and none of have worked for me.

我有两个表单,我需要在一个表单上按下按钮以将第二个表单上按钮的启用属性设置为 true.

What i have is two forms and what i need is for a button press on one form to set the enabled property of a button on my second form to true.

正如我所说,我已经尝试了多种方法,但到目前为止都没有奏效.

As i say i've tried multiple methods and none have worked so far.

推荐答案

您可以在第二个表单 PUBLIC 上创建一个按钮(您可以在 *cs 文件或 VS 中控件的属性"窗口中执行此操作)并添加第二个实例形成第一个.或者您可以在第二种形式中声明一些 delegate,以更改按钮属性,并调用它在第一个.其实还有更多的变种,我刚刚提到了2个:)

You can make a button on second form PUBLIC(you can do that in *cs file or from control's "properties" window in VS) and add instance of second form to the first one. Or you can declare some delegate in second form, to change button properties, and invoke it in the first one. Actually there are more variants, ive just mentioned 2 :)

这篇关于从另一个表单访问 Button 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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