答案 0 :(得分:0)
如果您想管理一个没有双击事件的控件,您可以使用时间戳来计算点击之间的时差。喜欢:
DateTime lastClickDate = DateTime.Now;
private void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
{
//You can change the value 1200 as you want.
if ((DateTime.Now - lastClickDate).TotalMilliseconds < 1200)
{
MessageBox.Show("double clicked");
}
this.Text = (DateTime.Now - lastClickDate).TotalMilliseconds.ToString();
lastClickDate = DateTime.Now;
}
答案 1 :(得分:0)
除了上一个答案,我建议添加鼠标指针的位置。 Cursor.Position
在这方面会有所帮助。
DateTime lastClickDate = DateTime.Now;
int xPosition = Cursor.Position.X;
int yPosition = Cursor.Position.Y;
private void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
{
//You can change the value 1200 as you want.
if ((DateTime.Now - lastClickDate).TotalMilliseconds < 1200)
{
//Just for example I have given as equals it is better to allow
//some variation since mouse may be moved a little during clicks
if(Cursor.Position.X==xPosition && Cursor.Position.Y==yPosition)
{
MessageBox.Show("double clicked");
}
}
this.Text = (DateTime.Now - lastClickDate).TotalMilliseconds.ToString();
lastClickDate = DateTime.Now;
}