Пример #1
0
        private void Grid_PO_DragDrop(object sender, DragEventArgs e)
        {
            if (!view.IsRunning)
            {
                Point clientPoint = Grid_Mem.PointToClient(new Point(e.X, e.Y));

                if (e.Effect == DragDropEffects.Copy)
                {
                    var hitTestInfo = Grid_Mem.HitTest(clientPoint.X, clientPoint.Y);
                    if (hitTestInfo.ColumnIndex > 0 && hitTestInfo.RowIndex != -1)
                    {
                        Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[1].Value = Grid_Mem.Rows[idxDragRow].Cells[1].Value;
                        Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[2].Value = Grid_Mem.Rows[idxDragRow].Cells[2].Value;
                        Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[3].Value = Grid_Mem.Rows[idxDragRow].Cells[3].Value;
                        AUpdateForm(hitTestInfo.RowIndex, Grid_Mem.Rows[idxDragRow].Cells[1].Value.ToString(), Grid_Mem.Rows[idxDragRow].Cells[2].Value.ToString(), Convert.ToInt16(Grid_Mem.Rows[idxDragRow].Cells[3].Value));
                    }
                }
            }
        }
Пример #2
0
        private void Grid_PO_MouseDown(object sender, MouseEventArgs e)
        {
            var hitTestInfo = Grid_Mem.HitTest(e.X, e.Y);

            if (hitTestInfo.RowIndex != -1 && hitTestInfo.ColumnIndex > 0)
            {
                valueFromMouseDown = Grid_Mem.Rows[hitTestInfo.RowIndex].Cells[hitTestInfo.ColumnIndex].Value;
                idxDragRow         = hitTestInfo.RowIndex;
                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;
            }
        }