By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,017 Members | 1,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,017 IT Pros & Developers. It's quick & easy.

TreeView Mouse event behaviour puzzles

P: n/a
Hello everyone,

I am using MS .NET Framework 1.0 Version 1.0.3705 developing a C# client
application using SQL Server on the server side.

I am looking to implement drag & drop in a TreeView control. The operation
takes place entirely within this single control. There is no need to provide
for interaction with other controls, forms, applications etc. Both the drag
source item (a TreeNode) and the drag target item (another TreeNode) are
within the same TreeView.

I have tried using the ItemDrag/DoDragDrop/DragDrop approach but it isn't
cooperating. The DragDrop event just does not fire. NB: TreeView.AllowDrop =
true. Anyway, I thought I would use the old approach of
MouseDown/MouseMove/MouseUp but that isn't working either.

Even though this question is framed in the context of an attempt to
implement drag & drop, this is not really a question about that process. When
I changed to the MouseDown/MouseMove/MouseUp approach the MouseDown/MouseUp
pair started exhibiting some very strange behaviour.

The MouseDown Event is followed immediately by a MouseUp event even
though the mouse button has not been released.

This code:
///__________________________________________________ ______
private void TvwManager_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Console.WriteLine("Manager_MouseDown");
}
///__________________________________________________ ________________
private void TvwManager_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Console.WriteLine("Manager_MouseUp" );
}
///__________________________________________________ ________________
private void TvwManager_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Console.WriteLine("Manager_MouseMove" );
}

Produces this result:

Manager_MouseMove
....
Manager_MouseMove
Manager_MouseDown
Manager_MouseUp
Manager_MouseMove
....
Manager_MouseMove
Manager_MouseDown
Manager_MouseUp
....

Explained as follows
**cursor enters the control, start receiving MouseMove events
Manager_MouseMove
....Numerous MouseMove events occur in succession here
Manager_MouseMove
**Left Mouse button pressed and held down
Manager_MouseDown <<MouseDown occurs -- just as it should
Manager_MouseUp <<MouseUp follows immediately even though the mouse button
has not been released
Manager_MouseMove <<This sequence of MouseMoves occurs while the button is
down
....
**Left button is released but, of course, the MouseMove events keep coming
Manager_MouseMove

Manager_MouseDown <<Try it again...Sequence described above repeats: MouseDown
Manager_MouseUp <<followed immediately by MouseUp
etc...

What is going on here? Has anyone else observed this behaviour?
What's to be done about it?

--
Kia pai tō haere, e hoa mā!
Nā Plumer
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.