Normally, to move a column in a DataGridView
, you just click and drag. However, if you scroll immediately before this operation (which is quite common if you are moving columns), then you must click on the column before the click-and-drag. I thought this had something to do with the DataGridView
losing focus, so I listened for Scroll
events of type EndScroll
from the horizontal scroll bar and called Focus()
on the DataGridView
there. That did not work. Does someone know how I can move columns without the extra click in this case?
Asked
Active
Viewed 193 times
0

Little Endian
- 784
- 8
- 19
-
Anyone? Any comments that might push me in the right direction? – Little Endian Jul 01 '14 at 14:48
1 Answers
0
This looks like a WinForms
bug.
Decompiling System.Windows.Forms
helped me to find the solution : declare a DataGridView
child class and override the OnScroll
function this way :
protected override void OnScroll(ScrollEventArgs e)
{
base.OnScroll(e);
base.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
}

Bioukh
- 1,888
- 1
- 16
- 27