473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

double click on combobox

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!

Nov 16 '05 #1
3 4329
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!


Nov 16 '05 #2
Thanx a lot james, it worked :) Just for my own understanding, why doesnt
this work for a combo box
private void combobox_DoubleClick(object sender, System.EventArgs e)

Regards

Wajih
"James [MS-SDK]" <ja****@online.microsoft.com> wrote in message
news:3D**************@cpmsftngxa10.phx.gbl...
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.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:240677X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

I am developing a C# app. I want to do something when someone double clickson a combo box. But this event never fires. Any suggestions? Thanx!

Nov 16 '05 #3
It appears that the TextBox control inside the ComboBox control takes the
DoubleClick event.

Check out this thread:
http://www.dotnet247.com/247referenc...26/133777.aspx
--------------------
From: "Wajih-ur-Rehman" <wr*****@ro1.adiscon.com>
References: <uX**************@TK2MSFTNGP12.phx.gbl> <3D**************@cpmsftngxa10.phx.gbl>Subject: Re: double click on combobox
Date: Fri, 30 Apr 2004 11:19:32 +0500
Lines: 82
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: <uF**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 202.163.124.68
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP12
.phx.gblXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:240976
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Thanx a lot james, it worked :) Just for my own understanding, why doesnt
this work for a combo box
private void combobox_DoubleClick(object sender, System.EventArgs e)

Regards

Wajih
"James [MS-SDK]" <ja****@online.microsoft.com> wrote in message
news:3D**************@cpmsftngxa10.phx.gbl...
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!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP1

2
phx.gbl
>Xref: 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 doubleclicks >on a combo box. But this event never fires. Any suggestions? Thanx!
>
>
>
>



Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Uninvisible | last post by:
I have put together a db for a law firm to keep track of counterfeit activities. There are four parent tables: tblContact tblTransaction tblAction tblFile I have created a form,...
1
by: Alex K. | last post by:
I am using combo box with DropDownStyle = simple. Tried to use double click event but it does not work. I've got this.comboItems.DoubleClick += new...
4
by: perspolis | last post by:
hi I manage a double click event in a combo box.. but this event doesn't fire ???? I don't know why??
2
by: Anne | last post by:
Hello, I have a combobox in vb.net that I am trying to preform an action on if the user double clicks it. I have set the DoubleClick event but it does not fire. Has any one else seen this and...
1
by: MadCrazyNewbie | last post by:
Hey Group, How could I do it so if something isn`t listed in my ComboBox (It looks up a Database Coloumn), When a User Double Clicks on the ComboBox it brings up a form so they Can add it in...
5
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event...
0
by: Hardik Shah | last post by:
Hi, I want to create menu , when my user right click from combo box's list item. I use Contextmenu property of combobox and assign menu for it, but it only effected when combobox's list item not...
2
by: Hardik Shah | last post by:
Hi, I want to create menu , when my user right click from combo box's list item. I use Contextmenu property of combobox and assign menu for it, but it only effected when combobox's list item not...
1
by: fiaolle | last post by:
Hi I have a DataGrid with comboboxes and I'm woundering what runs when a user clicks in the DataGrid or ComboBox. When I choose something in the combobox with the KeyUp event nothing happens, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.