我在jQuery中有代码:
// Group of buttons
$(".buttons").click(function() {
// Do something with one button
$(this). ...
});
我在C#Window Forms中有另一个程序:
private void someButtons_Click(object sender, EventArgs e) {
// How to know which button was clicked?
// How to get an instance of that button?
}
非常感谢!
答案 0 :(得分:2)
你的意思是
private void someButtons_Click(object sender, EventArgs e) {
var button = (Button)sender;
}
答案 1 :(得分:1)
private void someButtons_Click(object sender, EventArgs e)
{
// How to get an instance of that button?
Button myButton = ((Button)sender);
// How to know which button was clicked?
string buttonId = myButton.ID;
}