共享功能中的访问控制 [英] Acess control in share function

查看:49
本文介绍了共享功能中的访问控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过共享函数访问控件?

How can I access my controls via shared functions?

推荐答案

您不能,因为静态方法没有对对象的引用.您需要传递它们,或者使用Application.Current.OpenWindows对象做一些令人讨厌的事情,以找到正确的形式并将其转换为正确的类型.无论哪种方式,您的控件都永远不会在窗体外部可见,只应公开要访问的属性.
You can''t, because a static method does not have a reference to the objects. You need to pass them in, or do some really nasty stuff with the Application.Current.OpenWindows object to find the right form and cast it to the right type. Either way, your controls should never be visible outside the form, only properties you want to access should be exposed.


如果要使用ASP.NET,只需添加控件即可甚至不在页面生命周期之外,所以为什么必须共享您的方法?
Just to add, if you''re using ASP.NET, your controls don''t even exist outside of your page lifecycle, so why do your methods have to be shared ?


这篇关于共享功能中的访问控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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