如何在Form2中访问主Form1类的对象 [英] how to access object of main Form1 class in Form2

查看:75
本文介绍了如何在Form2中访问主Form1类的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有两种形式的MainForm1和Form2.我想在form2中访问MainForm1的对象.请使用exp.

解决方案

进行回复,但这是不好的做法,但是如果您坚持要这样做,只需使控件/对象可访问性修饰符为public,并且只要实例化表单,就可以从可以访问该表单的任何位置进行访问.


<您可能还想看一下委托,以便form2可以在form1上运行方法


hi all,

i''ve two forms MainForm1 and Form2.i want to access object of MainForm1 in form2.Please reply with an exp.

解决方案

This is bad practice, but if you insist on doing it, just make the control/object accessibility modifier public, and as long as the form is instantiated, you can get to it from anywhere that can get to the form.


You probably also want to look at delegates so that form2 can then run methods on form1


这篇关于如何在Form2中访问主Form1类的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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