private void grid_PM_MouseDown(object sender, MouseEventArgs e) { var hitTestInfo = Grid_PM.HitTest(e.X, e.Y); if (hitTestInfo.RowIndex != -1 && hitTestInfo.ColumnIndex > 0) { valueFromMouseDown = Grid_PM[hitTestInfo.ColumnIndex, hitTestInfo.RowIndex].Value; idxDragColumn = hitTestInfo.ColumnIndex; if (valueFromMouseDown != null) { Size dragSize = SystemInformation.DragSize; dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize); } } else { dragBoxFromMouseDown = Rectangle.Empty; } }
private void grid_PM_DragDrop(object sender, DragEventArgs e) { if (!view.IsRunning) { Point clientPoint = Grid_PM.PointToClient(new Point(e.X, e.Y)); if (e.Effect == DragDropEffects.Copy) { string valueInCell = e.Data.GetData(typeof(string)) as string; var hitTestInfo = Grid_PM.HitTest(clientPoint.X, clientPoint.Y); if (valueInCell == null) { valueInCell = Grid_PM[hitTestInfo.ColumnIndex, hitTestInfo.RowIndex].Value.ToString(); } if (hitTestInfo.ColumnIndex > 0 && hitTestInfo.RowIndex != -1 && hitTestInfo.ColumnIndex == idxDragColumn) { if (Grid_PM[7, hitTestInfo.RowIndex].Value.ToString() == "SHT" && hitTestInfo.ColumnIndex == 7 && valueInCell == "") { Grid_PM[4, hitTestInfo.RowIndex].Value = Grid_PM[7, hitTestInfo.RowIndex].Value = ""; AUpdateData(hitTestInfo.RowIndex, 7, ""); AUpdateData(hitTestInfo.RowIndex, 4, ""); } else if (Grid_PM[7, hitTestInfo.RowIndex].Value.ToString() == "SHT" && hitTestInfo.ColumnIndex == 7 && valueInCell != "SHT") { Grid_PM[hitTestInfo.ColumnIndex, hitTestInfo.RowIndex].Value = valueInCell; Grid_PM[4, hitTestInfo.RowIndex].Value = ""; AUpdateData(hitTestInfo.RowIndex, hitTestInfo.ColumnIndex, valueInCell); AUpdateData(hitTestInfo.RowIndex, 4, ""); } else if (Grid_PM[7, hitTestInfo.RowIndex].Value.ToString() == "SHT" && hitTestInfo.ColumnIndex == 4) { Grid_PM[4, hitTestInfo.RowIndex].Value = Grid_PM[7, hitTestInfo.RowIndex].Value = ""; AUpdateData(hitTestInfo.RowIndex, 7, ""); AUpdateData(hitTestInfo.RowIndex, 4, ""); } else { Grid_PM[hitTestInfo.ColumnIndex, hitTestInfo.RowIndex].Value = valueInCell; AUpdateData(hitTestInfo.RowIndex, hitTestInfo.ColumnIndex, valueInCell); } if (valueInCell == "SHT") { Grid_PM[3, hitTestInfo.RowIndex].Value = ""; AUpdateData(hitTestInfo.RowIndex, 3, ""); Grid_PM[5, hitTestInfo.RowIndex].Value = ""; AUpdateData(hitTestInfo.RowIndex, 5, ""); Grid_PM[6, hitTestInfo.RowIndex].Value = ""; AUpdateData(hitTestInfo.RowIndex, 6, ""); CallSubView(hitTestInfo.RowIndex); } else if ((valueInCell == "ARA" || valueInCell == "ALA" || valueInCell == "LRQ" || valueInCell == "LLQ" || valueInCell == "LLA" || valueInCell == "LRA" || valueInCell == "LCA") && Grid_PM[7, hitTestInfo.RowIndex].Value.ToString() != "SHT") { Grid_PM[hitTestInfo.ColumnIndex, hitTestInfo.RowIndex].Value = ""; AUpdateData(hitTestInfo.RowIndex, hitTestInfo.ColumnIndex, ""); } } } } }