I've implemented this simple drag and drop between rows of a DataGridView
by following this example:
datagridview-drag-and-drop-rows
The grid has a checkbox column (DataGridViewCheckBoxColumn
) that is no longer clickable after the drag and drop has been implemented.
Maybe the events MouseMove
and MouseDown
bypass the checkbox's click, so I have tried to intercept the position of the mouse and get a reference to the underlying control (the checkbox) and check it programmatically, but without any success.
private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Control dgrid = sender as Control;
Point now = dgrid.PointToClient(Cursor.Position);
foreach (DataGridViewCheckBoxCell c in dgrid.Controls.OfType<DataGridViewCheckBoxCell>())
{
//check if the point is inside the area
}
...other drag&drop operations
}
But the dgrid.Controls.OfType<DataGridViewCheckBoxCell>()
seems to not have any cells inside (obviously there are many)