473,386 Members | 1,823 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,386 software developers and data experts.

Double click code never executes

Hi to all,

i have an app that i allow a drag and drop operation of picture boxes on a
panel.
when i drop a picture box i do the following so my newly dropped picture box
will be able
to respond to these 2 events:

pbox.MouseDown += new MouseEventHandler(pbox_MouseDown);
pbox.DoubleClick += new EventHandler(pbox_DoubleClick);

But although the code in MouseDown event executes correctly, the
pbox_DoubleClick
is never called...
It seems that because MouseDown is executing first, it cannot "understand"
the double click
and thus it;s code never executes...

Has anyone experienced this and come up to a solution ?

Below is the code for MouseDown event,

thanks a lot for any help!

private void pbox_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e) {
PictureBox pbox = (PictureBox) sender;
DragDropEffects myEffect;
FormInvoked = true;
switch (e.Button) {
case MouseButtons.Left: {
myEffect = pbox.DoDragDrop((Bitmap)
pbox.Image,DragDropEffects.Copy);
SetDefaultBox(pbox.Name);
break;
etc etc etc...
Nov 16 '05 #1
1 2661
objectref,

I think that this would be the case. Anytime you let up the mouse you
are starting a drag/drop operation which is going to cancel out the double
click timer (I think).

What you might have to do is on the mouse down, you would set a timer
(set to a little more than the double click timeout) and a flag indicating
that the mouse was down. Then, when the timer fires, if the double click
handler did not execute, then you would begin your drag/drop operation.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"objectref" <ob*******@mediatrel.com> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
Hi to all,

i have an app that i allow a drag and drop operation of picture boxes on a
panel.
when i drop a picture box i do the following so my newly dropped picture
box will be able
to respond to these 2 events:

pbox.MouseDown += new MouseEventHandler(pbox_MouseDown);
pbox.DoubleClick += new EventHandler(pbox_DoubleClick);

But although the code in MouseDown event executes correctly, the
pbox_DoubleClick
is never called...
It seems that because MouseDown is executing first, it cannot "understand"
the double click
and thus it;s code never executes...

Has anyone experienced this and come up to a solution ?

Below is the code for MouseDown event,

thanks a lot for any help!

private void pbox_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e) {
PictureBox pbox = (PictureBox) sender;
DragDropEffects myEffect;
FormInvoked = true;
switch (e.Button) {
case MouseButtons.Left: {
myEffect = pbox.DoDragDrop((Bitmap)
pbox.Image,DragDropEffects.Copy);
SetDefaultBox(pbox.Name);
break;
etc etc etc...

Nov 16 '05 #2

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

Similar topics

2
by: Rob Mayo | last post by:
OK, maybe this is my opinion, maybe these are bugs. Given the folowing: I have a NotifyIcon on my Form, a Context menu associated with the NotifyIcon, and a MenuItem on the ContextMenu set as...
28
by: n00m | last post by:
When I double-click on "some.py" file console window appears just for a moment and right after that it's closed. If this script is started from inside of IDLE (F5 key) then it executes as it should...
6
by: Richard A. Lowe | last post by:
I'm using P/Invoke to call SendInput (using code culled from these newsgroups!) to send mouse events to a window. But I'm unsure how to send double-clicks. A VB6 article I saw on SendInput...
3
by: Wajih-ur-Rehman | last post by:
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!
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...
1
by: scott_gui | last post by:
Creating a Windows application: <Double-Button-1> mouse event has a conflict when there is also a binding to the <Button-1> event. It seems like a silly oversight that performing a double click...
9
by: Armando | last post by:
I have an app (A2000) where I am letting the user move an object on the screen. I use the OnClick for a command button event to modify the object's Top (or Left) properties, but you can only click...
2
by: techsatish | last post by:
Hi, I want the double click event to call(here not able to get the MouseEventArgs) and execute the mouseup event code or any one tell me how to make my treecontrol double click nodes to behave...
6
by: Jim Devenish | last post by:
I have an unbound form that displays all the days of the year as a calendar. It has 12 rows of text boxes with either 29,30 or 31 in each row. Text box names are of the form: display_01_01,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.