Ejemplo n.º 1
0
        private void ReorderRow(GridPanel panel)
        {
            if ((_MouseDownHitRow != _SeparatorRow) &&
                (_MouseDownHitRow != null && _SeparatorRow != null))
            {
                if (_SeparatorRow.IsChildOf(_MouseDownHitRow) == false)
                {
                    GridContainer mcont = _MouseDownHitRow.Parent as GridContainer;
                    GridContainer ncont = _SeparatorRow.Parent as GridContainer;

                    if (mcont != null && ncont != null)
                    {
                        int n = ncont.Rows.IndexOf(_SeparatorRow);
                        int m = mcont.Rows.IndexOf(_MouseDownHitRow);

                        if (panel.RowDragBehavior == RowDragBehavior.GroupMove)
                        {
                            if (IsSeparatorAtBottom == true &&
                                ((Control.ModifierKeys & Keys.Control) == Keys.Control))
                            {
                                n = 0;
                                ncont = _SeparatorRow;

                                IsSeparatorAtBottom = false;
                            }
                        }

                        if (m >= 0 && n >= 0)
                        {
                            if (ncont == mcont)
                            {
                                if (n > m && IsSeparatorAtBottom == false)
                                    n--;

                                else if (m > n && IsSeparatorAtBottom == true)
                                    n++;

                                if (m == n)
                                    return;
                            }
                            else
                            {
                                if (IsSeparatorAtBottom == true)
                                    n++;
                            }

                            if (SuperGrid.DoRowMovingEvent(this, mcont, m, ref ncont, ref n) == false)
                            {
                                _MouseDownHitRow.IsSelected = false;

                                mcont.Rows.RemoveAt(m);
                                ncont.Rows.Insert(n, _MouseDownHitRow);

                                panel.UpdateIndicees(panel, panel.Rows, true);

                                if (_MouseDownHitRow.IsExpandedVisible == true)
                                    _MouseDownHitRow.IsSelected = true;

                                ncont.InvalidateRender();

                                SuperGrid.DoRowMovedEvent(
                                    mcont.GridPanel, mcont, _MouseDownHitRow);
                            }
                        }
                    }
                }
            }
        }