Jav*_*ram 9 c# mouseevent winforms
在MS-Word 鼠标单击事件中用作:
单击 - 放置光标
双击 - 选择单词
三击 - 选择段落
在C#中,我可以处理单点击和双点击鼠标事件,但我想Triple Mouse Click在C#Windows TextBox中处理事件.
例:
void textbox1_TripleClick()
{
MessageBox.Show("Triple Clicked");
}
Run Code Online (Sandbox Code Playgroud)
看看这个: Mousebuttoneventargs.clickcount
我认为这应该涵盖它.
小智 5
做这个:
private int _clicks = 0;
private System.Windows.Forms.Timer _timer = new System.Windows.Forms.Timer();
private void txtTextMessage_MouseUp(object sender, MouseEventArgs e)
{
_timer.Stop();
_clicks++;
if (_clicks == 3)
{
// this means the trip click happened - do something
txtTextMessage.SelectAll();
_clicks = 0;
}
if (_clicks < 3)
{
_timer.Interval = 500;
_timer.Start();
_timer.Tick += (s, t) =>
{
_timer.Stop();
_clicks = 0;
};
}
}
Run Code Online (Sandbox Code Playgroud)