Ejemplo n.º 1
0
        private void CustomDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            Point ScreenPoint;
            Point CellOriginPoint;

            ScreenPoint = CustomDataGridView1.PointToScreen(CustomDataGridView1.CurrentCell.ContentBounds.Location);                                                                    //  Get the point on the screen where the DGV starts
            CellOriginPoint = new Point(CustomDataGridView1.GetCellDisplayRectangle(0, e.RowIndex, false).X, CustomDataGridView1.GetCellDisplayRectangle(0, e.RowIndex, false).Y);      //

            SortDGV.frmMovePositionPopup ReorderForm = new SortDGV.frmMovePositionPopup();                                                                                  // Instantiate a new popup form

            ReorderForm.Location = new Point(100, 100);                                                                   //  Combine the Screen point and DGV point

            ReorderForm.Location = new Point(ScreenPoint.X + 20, ScreenPoint.Y + CellOriginPoint.Y - 7);                                                                   //  Combine the Screen point and DGV point

            ReorderForm.btnApply.Click += new System.EventHandler(
                (aa, bb) => MoveLineItem(
                                        sender,
                                        e,
                                        Convert.ToInt32(ReorderForm.txtNewPositionNumber.Text)
                                     )
                );                                                                                                                 // add the event handler  (using a lambda expression)

            ReorderForm.ShowDialog();                                                                                                                                                      //
        }
Ejemplo n.º 2
0
        private void SpawnReorderPopup(object sender, DataGridViewCellEventArgs e)
        {
            Point ScreenPoint;
            Point CellOriginPoint;

            try
            {

                ScreenPoint = dataGridView1.PointToScreen(dataGridView1.CurrentCell.ContentBounds.Location);                                                                    //  Get the point on the screen where the DGV starts
                CellOriginPoint = new Point(dataGridView1.GetCellDisplayRectangle(0, e.RowIndex, false).X, dataGridView1.GetCellDisplayRectangle(0, e.RowIndex, false).Y);      //

                SortDGV.frmMovePositionPopup ReorderForm = new SortDGV.frmMovePositionPopup();                                                                                  // Instantiate a new popup form

                ReorderForm.Location = new Point(ScreenPoint.X + 20, ScreenPoint.Y + CellOriginPoint.Y - 7);                                                                   //  Combine the Screen point and DGV point

                ReorderForm.btnApply.Click += new System.EventHandler(
                    (aa, bb) => MoveLineItem(
                                            sender,
                                            e,
                                            Convert.ToInt32(ReorderForm.txtNewPositionNumber.Text)
                                         )
                    );                                                                                                                 // add the event handler  (using a lambda expression)

                ReorderForm.ShowDialog();                                                                                                                                                      //
                //ReorderForm.Show();
            }

            catch (Exception)
            {

                //MessageBox.Show(exc.GetType.ToString() + " " +   exc.Message);    //throw;
            }
        }