在我的代码中,我有一个button
和一个textbox
. 我想通过点击button
,将变量 k 的值发送到textbox
. 但是当我单击按钮时,我的代码没有任何问题。这是我的代码。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public delegate string fac(int x);
public static fac intostring = factory;
public static string inst= null;
public static string factory(int x)
{
inst = x.ToString();
return inst;
}
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);
}
}
}
public void uu(string newvalue)
{
this.textBox1.Name = (newvalue);
}
static int k=0;
private void button1_Click(object sender, EventArgs e)
{
k = 1;
intostring(k);
}
private void Form1_Load(object sender, EventArgs e)
{
EventExample myevt = new EventExample();
myevt.Valuechanged += new myeventhandler(uu);
myevt.val = inst;
}
}
}