private void DataGridViewListas_DragOver(object sender, DragEventArgs e) { var clientPoint = DataGridViewListas.PointToClient(new Point(e.X, e.Y)); var hittest = DataGridViewListas.HitTest(clientPoint.X, clientPoint.Y); if (hittest.RowIndex == DataGridViewListas.CurrentRow.Index || hittest.RowIndex == DataGridViewListas.Rows.Count - 1) { e.Effect = DragDropEffects.None; } else { e.Effect = DragDropEffects.Move; } }
private void DataGridViewListas_DragDrop(object sender, DragEventArgs e) { int NovaLista; // The mouse locations are relative to the screen, so they must be // converted to client coordinates. var clientPoint = DataGridViewListas.PointToClient(new Point(e.X, e.Y)); // If the drag operation was a copy then add the row to the other control. if (e.Effect != DragDropEffects.Move) { return; } var hittest = DataGridViewListas.HitTest(clientPoint.X, clientPoint.Y); if (hittest.RowIndex == -1) { return; } NovaLista = _listas[hittest.RowIndex].ID; if (Database.ItemMove(_itemFromMouseDown.ID, NovaLista)) { ItensLoad(); } }