`我想以静态方法更改文本框文本。考虑到我不能在静态方法中使用“this”关键字,我该怎么做。换句话说,如何使对象引用文本框文本属性?
这是我的代码
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public delegate void myeventhandler(string newValue);
public class EventExample
{
private string thevalue;
public event myeventhandler valuechanged;
public string val
{
set
{
this.thevalue = value;
this.valuechanged(thevalue);
}
}
}
static void func(string[] args)
{
EventExample myevt = new EventExample();
myevt.valuechanged += new myeventhandler(last);
myevt.val = result;
}
public delegate string buttonget(int x);
public static buttonget intostring = factory;
public static string factory(int x)
{
string inst = x.ToString();
return inst;
}
public static string result = intostring(1);
static void last(string newvalue)
{
Form1.textBox1.Text = result; // here is the problem it says it needs an object reference
}
private void button1_Click(object sender, EventArgs e)
{
intostring(1);
}`