button.Click += new System.EventHandler(btn_Click);
private void btn_Click(object sender, EventArgs e)
{
//EventArgs继承自MouseEventArgs,所以可以强转
MouseEventArgs Mouse_e = (MouseEventArgs)e;
//点鼠标右键,return
if (Mouse_e.Button == MouseButtons.Right)
{
MessageBox.Show("右键!");
}
}
只有把EventArgs强制转换成MouseEventArgs就可以有相当于MouseDown事件的功能了
button2.MouseDown += new MouseEventHandler(btn2_MouseDown);
private void btn2_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
MessageBox.Show("右键");
}
}
黑色头发:http://heisetoufa.iteye.com/