button void btn1 _click(object sender,EventArgs e)
{
Button btn=(button)sender; //这一句的作用是什么??
}
EventArgs eçä½ç¨æ¯ä»ä¹å¢ï¼ï¼
追çè¿ä¸ªæ¯è¯¥è§¦å对象ä¹å°±æ¯btn1对åºçä¿¡æ¯ãå¯ä»¥éè¿ e.å±æ§æ¥è·åï¼å°±æ¯ä½ btnå®ä¹çä¸äºåæ°ãä¸é¢æä¸ªé¼ æ åå»çä¾åï¼ä½ èªå·±çå§ã
å¨ä½ ççªä½ä¸æ·»å ä¸ä¸ªLabelï¼åå»LabelçMouseClickäºä»¶ãæ·»å å¦ä¸æ¹æ³ï¼
private void label1_MouseClick(object sender, MouseEventArgs e)
{
Label senderLabel = (Label)sender;//æ ¹æ®senderå¼ç¨æ§ä»¶ã
senderLabel.Text = e.Button.ToString();//æ ¹æ®eä¸çButtonåæ°ï¼å¤ææ¯å·¦é®è¿æ¯å³é®ã
}
ç¶åå¨çªä½ä¸åå»ä½ çLabelï¼å°±ä¼æ¾ç¤ºä½ åå»çé¼ æ çæé®Rigleæè
Leftã
ââââââââââââââââââ
以Button为ä¾ï¼
protected void Button1_Click(object sender, EventArgs e)
å
¶ä¸çsender,å°±æ¯ä½ ç¹å»çbutton.å¯ä»¥éè¿ç±»å转æ¢å¾å°è¿ä¸ªbuttonçå¼ç¨ï¼
Button sendButton = (Button)sender;
eæ¯ä½ ç¹å»äºä»¶çä¸äºåæ°ã
æ¯å¦è¯´ä½ ç¨é¼ æ ç¹å»çªä½
é£ä¹EventArgsæ¯ä¼å
å«ç¹å»çä½ç½®ççåæ°
å®ç¨æ¥è¾
å©ä½ å¤çäºä»¶