当我按下按钮并在释放按钮时再拨打另一个按钮时,如何调用方法?
我正在使用我的C#WinForms应用程序中的PTT(按下通话)按钮。
答案 0 :(得分:2)
答案 1 :(得分:2)
private void button1_MouseDown(object sender, MouseEventArgs e)
{
// button is being pressed
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
// button was released
}
答案 2 :(得分:0)
也许是这样的事情:
private void btn1_MouseDown(object sender, MouseEventArgs e)
{
Console.WriteLine("Mouse Button was pressed down on the button");
}
private void btn1_MouseUp(object sender, MouseEventArgs e)
{
Console.WriteLine("Mouse button Button was released");
}
单击按钮后查看输出窗口。
好的尝试一下,在表单中添加一个文本框并将其命名为TextBox1,然后将此代码添加到后面的代码中:
private void btn1_MouseDown(object sender, MouseEventArgs e)
{
this.TextBox1.Text = "Mouse Button was pressed down on the button";
}
private void btn1_MouseUp(object sender, MouseEventArgs e)
{
this.TextBox1.Text = "Mouse button Button was released";
}