Пример #1
0
        private void butUp_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Please select exactly one referral first.");
                return;
            }
            int selectedIdx = gridMain.GetSelectedIndex();

            if (selectedIdx == 0)           //already at top
            {
                return;
            }
            RefAttach sourceAttach = ((RefAttach)gridMain.ListGridRows[selectedIdx].Tag);
            RefAttach destAttach   = ((RefAttach)gridMain.ListGridRows[selectedIdx - 1].Tag);
            int       sourceIdx    = sourceAttach.ItemOrder;

            sourceAttach.ItemOrder = destAttach.ItemOrder;
            RefAttaches.Update(sourceAttach);
            destAttach.ItemOrder = sourceIdx;
            RefAttaches.Update(destAttach);
            if (!gridMain.SwapRows(selectedIdx, selectedIdx - 1))
            {
                MsgBox.Show(this, "Unable to change order.");
                return;
            }
            gridMain.SetSelected(selectedIdx - 1, true);
        }