Search This Blog

Friday, October 14, 2011

Dragging and dropping rows between DataGridViews

Okay, I set out to reproduce code I have in VB6 with grids copying rows between grids to C# using DataGridView.
Works great except if more than one row is selected. Found this article below

Turns out MouseDown event unselects all but the row under the mouse cursor. To prevent this, I have to create a new custom control derived from DataGridView and overrride OnMouseDown() to prevent base.MouseDown() from firing if more than one row is selected.

This leaves me thinking...

I hate having to create a custom control every time I want to rid a winform control of a bad behavior buffering or event related. Because this unwanted behavior is almost always found after form design is completed.
But this an epiphany occurred to me about winforms. I should consider creating custom controls for all of the standard controls you are using. Seems like a pain but control creation is easy and then I get much better control of my application rather than setting for Microsoft's default.

This is similar to the earlier epiphany I had concerning docking and anchoring controls, where if you make sure controls are in panels and splitters and then in turn these containers are placed in Flowlayoutpanels or tablelayoutpanels, UI design with WInform because understandable and actually fun.

Too bad, I can't this kind of incite to a dev language and platform before I start a new project.

having trouble with drag-n-drop of multiple items:

'via Blog this'

also http://adamhouldsworth.blogspot.com/2010/01/datagridview-multiple-row-drag-drop.html

No comments: