Drag and drop performance

  • Thread starter Thread starter Derrick
  • Start date Start date
D

Derrick

I have a VB form with a list box that is filled with objects. I have
written code to allow a user to drag and drop those objects from the list
box to a tree view. Everything is working really well except for the inital
drag and drop. The cursor does not update and it takes a few seconds to
update the controlls with the moved object. On subsequent attempts, the
cursor is updated immediately and the object is moved as fast as the mouse
is released.

Does anyone have suggestions of what would cause this? Or where in my code I
should be looking for the problem? or if this is a common occurance, is
there a workaround?

Derrick
 
Hi Derrick,

I'd like to know what objects did you Drag and drop from a listbox to the
Treeview?
I guess there is some lazy initialization when you do Drag and drop in the
first time, but there might be other reasons. could you send me a simple
reproduce sample for this issue?
I'd like to play with it to see if I could figure out something.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Thanks for the response. While I was pasting all the drap and drop related
code into this reply, I noticed the following try-catch block that loads
custom cursors when the drag was initiated. I had tested it on its own
before I used it in the project and it worked fine, so I didn't try
eliminating when I first found this performance problem. On a whim, I tried
the operation without the custom cursor, and the delay disappeared. My
custom cursors were not very important, so I just eliminated this code and
it was fine. My experience tells me that this code should not be causing
the delay, but you can't argue with evidence. Any thoughts on why it would
cause a problem?

<snip>
Try
MyNormalCursor = New Cursor("okDrop.cur")
MyNoDropCursor = New Cursor("noDrop.cur")
Catch
UseCustomCursors = False
</snip>

Thanks

Derrick
 
Hi Derrick,
Are you sure those lines don't throw an exception. Usually exceptions are
what brings the performance down.

--
B\rgds
100 [C# MVP]

Derrick said:
Thanks for the response. While I was pasting all the drap and drop related
code into this reply, I noticed the following try-catch block that loads
custom cursors when the drag was initiated. I had tested it on its own
before I used it in the project and it worked fine, so I didn't try
eliminating when I first found this performance problem. On a whim, I tried
the operation without the custom cursor, and the delay disappeared. My
custom cursors were not very important, so I just eliminated this code and
it was fine. My experience tells me that this code should not be causing
the delay, but you can't argue with evidence. Any thoughts on why it would
cause a problem?

<snip>
Try
MyNormalCursor = New Cursor("okDrop.cur")
MyNoDropCursor = New Cursor("noDrop.cur")
Catch
UseCustomCursors = False
</snip>

Thanks

Derrick


"Ying-Shen Yu[MSFT]" said:
Hi Derrick,

I'd like to know what objects did you Drag and drop from a listbox to the
Treeview?
I guess there is some lazy initialization when you do Drag and drop in the
first time, but there might be other reasons. could you send me a simple
reproduce sample for this issue?
I'd like to play with it to see if I could figure out something.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
When I first tested it, It wasn't entering the catch block. But after your
message, I thought I should test it again - and now the code does throw an
exception (because I had my cursors in the wrong folder). I had a
messagebox in the first line of the catch during my development and testing
phase, so it should have fired when I encountered the problems in the first
place.

Hopefully that doesn't happen again.

Thanks for help.

Derrick

I move the cursor files into the right folder and retested and the delay
disappeared.
Stoitcho Goutsev (100) said:
Hi Derrick,
Are you sure those lines don't throw an exception. Usually exceptions are
what brings the performance down.

--
B\rgds
100 [C# MVP]

Derrick said:
Thanks for the response. While I was pasting all the drap and drop related
code into this reply, I noticed the following try-catch block that loads
custom cursors when the drag was initiated. I had tested it on its own
before I used it in the project and it worked fine, so I didn't try
eliminating when I first found this performance problem. On a whim, I tried
the operation without the custom cursor, and the delay disappeared. My
custom cursors were not very important, so I just eliminated this code and
it was fine. My experience tells me that this code should not be causing
the delay, but you can't argue with evidence. Any thoughts on why it would
cause a problem?

<snip>
Try
MyNormalCursor = New Cursor("okDrop.cur")
MyNoDropCursor = New Cursor("noDrop.cur")
Catch
UseCustomCursors = False
</snip>

Thanks

Derrick


"Ying-Shen Yu[MSFT]" said:
Hi Derrick,

I'd like to know what objects did you Drag and drop from a listbox to the
Treeview?
I guess there is some lazy initialization when you do Drag and drop in the
first time, but there might be other reasons. could you send me a simple
reproduce sample for this issue?
I'd like to play with it to see if I could figure out something.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi Derrick,
Why don't you put your cursors as embedded resources in your assembly. That
way you don't have to remember to move them along with the assembly

--
B\rgds
100 [C# MVP]
Derrick said:
When I first tested it, It wasn't entering the catch block. But after your
message, I thought I should test it again - and now the code does throw an
exception (because I had my cursors in the wrong folder). I had a
messagebox in the first line of the catch during my development and testing
phase, so it should have fired when I encountered the problems in the first
place.

Hopefully that doesn't happen again.

Thanks for help.

Derrick

I move the cursor files into the right folder and retested and the delay
disappeared.
Stoitcho Goutsev (100) said:
Hi Derrick,
Are you sure those lines don't throw an exception. Usually exceptions are
what brings the performance down.

--
B\rgds
100 [C# MVP]

Derrick said:
Thanks for the response. While I was pasting all the drap and drop related
code into this reply, I noticed the following try-catch block that loads
custom cursors when the drag was initiated. I had tested it on its own
before I used it in the project and it worked fine, so I didn't try
eliminating when I first found this performance problem. On a whim, I tried
the operation without the custom cursor, and the delay disappeared. My
custom cursors were not very important, so I just eliminated this code and
it was fine. My experience tells me that this code should not be causing
the delay, but you can't argue with evidence. Any thoughts on why it would
cause a problem?

<snip>
Try
MyNormalCursor = New Cursor("okDrop.cur")
MyNoDropCursor = New Cursor("noDrop.cur")
Catch
UseCustomCursors = False
</snip>

Thanks

Derrick


Hi Derrick,

I'd like to know what objects did you Drag and drop from a listbox
to
the
Treeview?
I guess there is some lazy initialization when you do Drag and drop
in
the
first time, but there might be other reasons. could you send me a simple
reproduce sample for this issue?
I'd like to play with it to see if I could figure out something.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Back
Top