在我的代碼中,我有一個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;
}
}
}
它一個int轉換爲字符串 – user1853846 2013-03-17 23:00:54