å 为Clickäºä»¶çç±»åæ¯EventHandlerï¼
å
¶å®ä¹æ¯ public delegate void EventHandler (Object sender,EventArgs e)ã
ä¹å°±æ¯è¯´ï¼åæ°ç±»åæ¯åºå®çï¼æä»¥ä½ ä¸è½èªå·±é便æ¹ã
å¯ä»¥è¿æ ·åï¼å¨æå建buttonæ¶ï¼ç»buttonçtagï¼æè
å
¶ä»å±æ§ï¼èµå¼ï¼ä½¿ç¨çæ¶åå¤æä¸å°±å¥½äºã
å建ï¼
Button button = new Button();
button.Tag = 1;
button.Click = button_Click;
使ç¨ï¼
private void button_Click(object sender,EventArgs e)
{
Button button = sender as Button;
if(button == null) return;
if(button.Tag==1)
{
// to do ...
}
if(button.Tag==2)
{
// to do ...
}
}
温馨提示:内容为网友见解,仅供参考