468,117 Members | 1,864 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

TreeView Mouse event behaviour puzzles

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)
///__________________________________________________ ________________
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:


Explained as follows
**cursor enters the control, start receiving MouseMove events
....Numerous MouseMove events occur in succession here
**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
**Left button is released but, of course, the MouseMove events keep coming

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

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
0 1387

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jacek Jurkowski | last post: by
5 posts views Thread by A-PK | last post: by
reply views Thread by Plumer | last post: by
3 posts views Thread by sianan | last post: by
10 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.