C#静态方法/功能改变按钮背面的颜色 [英] C# static methods/functions change buttons back color

查看:54
本文介绍了C#静态方法/功能改变按钮背面的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在form1类的静态函数中更改按钮的背景颜色,但不允许这样做。有可能吗?

I want to change background color of a button in a static function in my form1 class but it's not allowed. Is there a possible way??

public static void change()< =使用这个我想改变按钮的颜色

public static void change() <= using this i want to change back color of button

谢谢

推荐答案

为什么要使用静态方法?静态方法只能使用静态属性/字段。无法访问实例属性/字段。有很多方法可以做到这一点。所以引入上下文会更好。

Why do you want to use static method? Static method can use only static properties/fields. There is not access to instance properties/fields. There are many methods how to do it. So it would be better to introduce context.


这篇关于C#静态方法/功能改变按钮背面的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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