静态方法里面怎么对实例化的变量进行改变?

shanyang1 2013-05-15 10:42:28
某静态方法,用来刷新form上面的label
static refresh()
{
this.label1 = "xxx";
}
报错,静态方法里面不能用this
请问怎么解决?
...全文
155 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
love_4023 2013-05-15
  • 打赏
  • 举报
回复

        public Form1()
        {
            InitializeComponent();
            this.radLabel1.Text = refresh();
        }

        static string refresh()
        {
            return "xxx";
        }
yqb_last 2013-05-15
  • 打赏
  • 举报
回复
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsAp { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { AMehod(textBox1); } public static void AMehod(TextBox tb) { tb.Text = "abdc"; } } }
shanyang1 2013-05-15
  • 打赏
  • 举报
回复
1,必须用静态方法 2,该静态方法要改变当前form上的控件 3,异步快速刷新控件,可能会用到begininvoke

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧