You can capture the double click by keeping track of the time between
clicks. Here's an example using the MouseDown event. Note that you could
use the Click event just as easily.
using System;
using System.Drawing;
using System.Windows.Forms;
class DoubleClickCombo : Form
{
ComboBox box = new ComboBox();
// Keeps track of the time of the last click
DateTime LastClick = DateTime.Now;
public DoubleClickCombo()
{
// Combo box
box.Location = new Point(5, 5);
box.Parent = this;
box.MouseDown += new MouseEventHandler(box_MouseDown);
}
private void box_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
TimeSpan Current = DateTime.Now - LastClick;
TimeSpan DblClickSpan =
TimeSpan.FromMilliseconds(SystemInformation.Double ClickTime);
if (Current.TotalMilliseconds <= DblClickSpan.TotalMilliseconds)
{
// Code to handle double click goes here
}
LastClick = DateTime.Now;
}
}
}
--------------------
From: "Wajih-ur-Rehman" <wr*****@ro1.adiscon.com>
Subject: double click on combobox
Date: Thu, 29 Apr 2004 12:35:29 +0500
Lines: 5
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uX**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 202.163.124.68
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP12
.phx.gblXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:240677
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
I am developing a C# app. I want to do something when someone double clicks
on a combo box. But this event never fires. Any suggestions? Thanx!