在静态方法访问非静态combbox财产 [英] Accessing non-static combbox property in the static method

查看:184
本文介绍了在静态方法访问非静态combbox财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框窗形式,我有一个与静态的声明像一种方法私有静态数据表ParseTable(HtmlNode表)现在我想使用组合框的该方法使用组合框属性,但我不能访问组合框或组合框的任何财产生命本身我做了组合框的声明为静态则可以在静态method.But访问combbox属性静态的方法,因为任何其他的方式进行访问我不想让组合框的声明为static。

I have one combobox on the window form and I have one method which is declared with static like private static DataTable ParseTable(HtmlNode table) Now I want to use combobox in that method for using combobox property but I can not access any property of combobox or combobox itself.If I made the combobox declaration as static then it can be accessed in that static method.But any alternative way to access combbox property in that static method because I don't want to make combobox declaration as static.

推荐答案

您可以通过组合框作为参数传递给你的方法。为什么你需要有 ParseTable 方法的静态的?

You can pass combobox as a parameter to your method. Why do you need to have ParseTable method as static?

更新:您无法访问的非静态的一类的成员在静态情况下。所以,你唯一可以做的,如果你还需要有使用方法的参数静态方法以某种方式通过你的组合框到那个方法。

Update: You cannot access non-static members of a class in static context. So the only thing you can do if you still need having a static method is somehow passing your combobox to that method using method's parameters.

这篇关于在静态方法访问非静态combbox财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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