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

doubleclick won't fire if dragdrop once implemented?

Hello,

I've added drag-and-drop feature to a windows forms label control which is
contained in a panel. And I added a doubleclick event handler to the
drag-and-drop-abled label, but doubleclick event never happen to the label.
What did I wrong? Or is it a .NET bug? (Similar discussions I found:
http://groups.google.co.kr/groups?hl...6newwindow%3D1)

Sample source codes follows:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private System.ComponentModel.Container components = null;
int m_MouseXPositionInLabel1;
int m_MouseYPositionInLabel1;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Code Generated by Windows Form Designer
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.AllowDrop = true;
this.panel1.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(255)) , ((System.Byte)(255)),
((System.Byte)(192)));
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(292, 273);
this.panel1.TabIndex = 0;
this.panel1.DragEnter += new
System.Windows.Forms.DragEventHandler(this.panel1_ DragEnter);
this.panel1.DragDrop += new
System.Windows.Forms.DragEventHandler(this.panel1_ DragDrop);
//
// label1
//
this.label1.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(128)) , ((System.Byte)(255)),
((System.Byte)(128)));
this.label1.Location = new System.Drawing.Point(56, 48);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "label1";
this.label1.DoubleClick += new
System.EventHandler(this.label1_DoubleClick);
this.label1.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.label1 _MouseDown);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion
private void label1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
// printing out current mouse posision
System.Diagnostics.Debug.WriteLine("X: " + e.X.ToString() + " Y: " +
e.Y.ToString());
this.m_MouseXPositionInLabel1 = e.X;
this.m_MouseYPositionInLabel1 = e.Y;
label1.DoDragDrop(label1, DragDropEffects.Move);
}

private void panel1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
// To set the label1's location to the new drag-drop location,
// get e.X and e.Y and subtract form's absolute location.
// "- 4 - this.m_MouseXPositionInLabel1" and "- 23 -
this.m_MouseYPositionInLabel1"
// done for exact drag-and-drop behavior on screen (4 and 23 may differ
on Windows themes?)
Point pt = label1.Location;
pt.X = e.X - this.Left - 4 - this.m_MouseXPositionInLabel1;
pt.Y = e.Y - this.Top - 23 - this.m_MouseYPositionInLabel1;
label1.Location = pt;
}

private void panel1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
// giving move effect on the mouse cursor
e.Effect = DragDropEffects.Move;
}

private void label1_DoubleClick(object sender, System.EventArgs e)
{
// PROBLEM -- doubleclick event handler is declared but never entered
System.Diagnostics.Debug.WriteLine("doubleclick event occurred");
}

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Nov 16 '05 #1
0 1370

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

Similar topics

4
by: Bright Sun | last post by:
Hi, I have a ListView that is shown in Details mode, and the Checkboxes property is set to true. My problem is that I dont want the checkboxes being activated when items in the ListView are...
0
by: Eric St-Onge | last post by:
Hi, I need to dragdrop message items from Outlook (2002 and 2003) to my application. I successfully implemented DragDrop from Explorer to MyApp but I didnt find how to properly code...
0
by: Flack | last post by:
Hello, Is it possible to find out how many methods are listening to a certain event? For example, if a number of methods subscribed to a controls DragDrop event using +=, can I find out how many...
5
by: David Lozzi | last post by:
Hey All, I have a listbox that I would like to fire an event on doubleclick. the onDoubleClick property of the listbox isnt available be default, and I know it will work with Javascript, but how...
3
by: active | last post by:
DoubleClick seems to work OK with a ListBox. However, with a ListView I never get the event fired. I looked at both the LIstBox and ListView events and neither lists the DoubleClick??? But...
2
by: active | last post by:
I'm about ready to give up unless someone has an idea. Trying to do in a ListView DragDrop and DoubleClick. I can make it work if they use different mouse buttons. But if I use the left...
3
by: C Glenn | last post by:
I would like one DoubleClick event handler to handle all double clicks throughout a DataGrid. I've assigned a DoubleClick event handler to the DataGrid and it works nifty-spiffy so long as I click...
2
by: Ryan Liu | last post by:
Hi, I need the MouseDown event be trigged everytime when you press mouse in a datagrid (System.Windows.Forms). But seems mouse event will only fire once, and it seems changed to edit mode...
1
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
how can i fire event on doubleclick and what function/and how do i read the selected list of values? thnaks in advance peleg
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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,...
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.