private void btnDown_Click(object sender, EventArgs e) { if (grdSortKeys.SelectedItems.Count > 0) { CustomSortKey sortKey = (CustomSortKey)grdSortKeys.SelectedItems[0].GetRow().DataRow; int index = sortKeys.IndexOf(sortKey); if (index < sortKeys.Count - 1) { sortKeys.RemoveAt(index); sortKeys.Insert(index + 1, sortKey); RebindControls(); grdSortKeys.SelectedItems.Clear(); grdSortKeys.SelectedItems.Add(index + 1); } } }
private void btnRemove_Click(object sender, EventArgs e) { if (grdSortKeys.SelectedItems.Count > 0) { CustomSortKey sortKey = (CustomSortKey)grdSortKeys.SelectedItems[0].GetRow().DataRow; if (grdSortKeys.Row == sortKeys.Count - 1) { grdSortKeys.Row = (sortKeys.Count - 2 > 0) ? (sortKeys.Count - 2) : 0; } availableColumns.Add(sortKey.Column); grdSortKeys.SelectedItems.Clear(); grdSortKeys.SelectedItems.Add(sortKeys.Count - 1); sortKeys.Remove(sortKey); RebindControls(); } }