Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGridView disable auto scrolling during drag&drop operation
 

DataGridView disable auto scrolling during drag&drop operation

I have a datagridview and a listbox. I implemented a drag and drop from the listbox to datagridview. Everything works except that when I drag an item from the listbox into the datagridview, and when the cursor is over the right or the bottom near the scrollbars, the grid scrolls automatically. Although it's a welcome behavior I'd like to put a delay on it such that it only scrolls after a short delay. This automatic scrolling seems to be inherent. But only on the right and bottom side. I had to implement custom scrolling on the top and left - when the cursor is over the column and row headers respectively - which is puzzling that there is no inherent support for that.

Any ideas?
Thanks
doughboy  Tuesday, August 18, 2009 5:00 PM
I found out what the source of the issue was.

In my DragOver event handler, I was doing a hit test and setting CurrentCell to cell from the hit test.
And apparently, if the cell being set current isn't fully visible - as is in my case near the scrollbars as can be seen in the screenshot -, grid scrolls just enough to bring it in full view. That has the scroll effect. And since there would be yet another partial cell under the cursor after the scroll, it'll repeat until we have scrolled all the way to the last column.

Thanks for following up.
doughboy  Wednesday, August 26, 2009 7:41 PM
Hi doughboy,

What does the "right or the bottom near the scrollbar" mean? Do you mean the behavior happens when you drag over that area?

I appreciate if you can post the screen shot to tell me. Picture are powerful than word. You can upload the picture to the http://skydrive.live.com

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Thursday, August 20, 2009 2:21 AM
Thanks for the tip about skydrive.

http://cid-e9f285e03800bd81.skydrive.live.com/self.aspx/Public/mock%7C_grid.JPG

When I drag an item and hover around the circled area, the gridview will scroll automatically.
However, I cannot get it to scroll automatically on the opposite sides to scroll up or left, is what I am saying.
Hope that makes it clearer.

Thanks
doughboy  Thursday, August 20, 2009 2:38 PM
Hi doughboy,

Thank you for the screen shot. It did help a lot to make the question clear. After I test it on my computer, I found even I drag over the scrollbar, it didn't scroll. So I think the DataGridView won't auto scroll by default. Did you set some property that let it scroll? Could you please create a simple project and add a DataGridView to test it?

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Friday, August 21, 2009 2:23 AM
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Tuesday, August 25, 2009 8:56 AM
I found out what the source of the issue was.

In my DragOver event handler, I was doing a hit test and setting CurrentCell to cell from the hit test.
And apparently, if the cell being set current isn't fully visible - as is in my case near the scrollbars as can be seen in the screenshot -, grid scrolls just enough to bring it in full view. That has the scroll effect. And since there would be yet another partial cell under the cursor after the scroll, it'll repeat until we have scrolled all the way to the last column.

Thanks for following up.
doughboy  Wednesday, August 26, 2009 7:41 PM

You can use google to search for other answers

Custom Search

More Threads

• render DB images as thumbnails in read-only Datagridview...
• Deployment of an application on user machines - VB.NET
• Binding Image to the Column of the Gridview using C#
• DataGridView row off by one question
• Private Message Queue is locked, unknown reason
• binding combobox to object
• DataBinding Radiobuttons..
• Window forms control size
• Color in DataGridView
• [C#]progress form while insert or update