Help with double-click and drag-drop

B

Bill Angus

Hi: I posted this 3 days ago in another V-Studio2005 group and got no
replies. There seems to be better response to requests in this group. Hope
nobody minds me trying for an answer here.

I have windows forms .Net 2 app. in which I was using double click to
activate a form. I also wanted to be able to drag items out of one form onto
another. I got both working separately, but I can't seem to get them to work
together. The mousedown event is trapped by my drag-drop routine. This
prevents double-click. As soon as mousedown fires, the app thinks it is
dragging out. The datagridview control will not accept to have both
double-=click and drag-drop both as possible user-actions.

Any help or ideas will be greatly appreciated.

Thanks and have a great day!

Bill Angus, MA
http://www.psychtest.com
 
J

Jared

Have you seen the 'AllowDrop' property and natarual events that it exposes.

Sounds like your trying to program drop drag manually

Also, from what are your trying to D&D to?

Form1 -> form2
form2 -> form1

-or-

form1.control1 -> form2.control2
from2.control2 -> form1.control1
 
S

Stoitcho Goutsev \(100\)

Bill,

This will always be a problem if you start the D&D operation on mouse down.
To solve this problem and to make the user experience better applications
start D&D operation when the user presses the mouse and moves the mouse at
some distance from the poing where the mouse has been pressed. Very often
users move a mouse a little bit when pressing the mouse button it doesn't
meen thought that they want to D&D something. Windows has a system defined
value that say how big is the distance past which the operation should be
considered as 'drag' (see SystemInformation.DragSize).
 
B

Bill Angus

Dear Jared:

thanks for your reply

What I am trying to do (in different places in my app.) is to drag from to
form to form in one instance, and from control - form in another instance
(specifically in the 2nd instance I am draggin out of a row within a
datagridview control). I have programmed the mousedown on all the controls
on the form to begin drag-drop in instance 1. I have only programmed the
datagridview control in instance 2. The allow drop property probably doesn't
have much to do with this, as it is the starting of the drag that is giving
the problem.

I programmed the drag-drop using mouse-down -- exactly as described in the
docs (docs are admitedly a bit skimpy in this area). There seems to be a bug
in the std .net objects (i.e. datagridview and text-box, as they are not
able to differentiate between mouse down (holding the mouse key down) and
double-click. I guess these controls were developed for use in environments
other than windows. Perhaps in non-windows environment, identifying and
responding to both a double-click and a drag-out, may not be a standard
required behavior for any control.

Do you have any ideas as to how one might go about using both (1) drag-out
from a control and (2) double-click of the control? It would seem idiotic to
have to subclass the control and to write a special custom version to be
able to use double-click as well as drag-drop.
--------------------------
here is the event I programmed.
-------------------------
Private Sub InventoryDetailGridView_MouseDown(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
InventoryDetailGridView.MouseDown

Dim iMyItem = InventoryDetailGridView.CurrentRow.Cells(0).Value

If IsNothing(iMyItem) Then

MessageBox.Show("Nothing to Copy", "Can't drag non-existent Item",
MessageBoxButtons.OK, MessageBoxIcon.Information)

Else

Me.DoDragDrop("PMI" + Str(iMyItem), DragDropEffects.Copy)

End If

End Sub

--------------------
note that the above event works just great... BUT programming this event
disables the double-click event for the control's row-header. The control
seems to intercept the mouse-down which is really supposed to be the
beginning of the double-click. It also intercepts every other click (no
matter how fast) as additional mouse-down 's.

Thanks and have a great day!

Bill Angus, MA
http://www.psychtest.com
 
B

Bill Angus

Thanks a million Stoitcho.

I think you have identified the problem -- though perhaps not a perfect
solution. Can you tell me is there no application-wide way to set drag-size
for a windows app? The systeminformation class has exclusively read-only
properties as far as I can tell. This is unfortunate because temporarily
changing the dragsize property would certainly fix the problem. But I don't
really want to change things for the user's windows installation (outside of
the application).

Is it that .net is designed in such a way that windows system must be
changed
and there is no way around this?

Thanks and have a great day!

Bill Angus, MA
http://www.psychtest.com
 
S

Stoitcho Goutsev \(100\)

Bill,

This setting is only for information. The developer should take care of
implementing their logic using this value as a reference. It is there just
to make sure that all applications behave in the same way. If you want to
use different value in your implementation just go ahead and use it. What I
want to say is that nothing comes out of the box you need to take care
tracking the mouse clicks and movements and start the d&d having in mind
this value.
 
B

Bill Angus

I have worked more with the docs and am still confused. I do see a lot of
low-level programming stuff like subclassing the controls and intercepting
the mousedown even (plus providing a complex handler that times the clicks
and dispatches all the possible mouse action events )

Can you tell me... Is it not possible just to change the operating system
default "dragsize" property from within the windows forms application? I
can't see how to do this in the docs.

Thanks
 
S

Stoitcho Goutsev \(100\)

Bill,

I still don't understand why you want to change this. Again just changing
this property won't fix the problem in your application. you have to
implement your logic not to start d&d unless the mouse cursor has been moved
away from the location where the mouse button has been pressed down. What is
the distance beyond which you should start the d&d operaton is completely up
to you. If you don't want to hard code any value the best is to use the
system setting that I was talking about.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top