在我的代码中,我有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;
}
}
}
答案 0 :(得分:0)
只需在button1_Click
private void button1_Click(object sender, EventArgs e)
{
k = 1;
intostring(k);
this.textBox1.Text = thevalue;
}