private void ButtonRight_Click(object sender, EventArgs e) { var selectedRows = EnabledView.SelectedRows; if (selectedRows.Count == 0) { System.Media.SystemSounds.Asterisk.Play(); return; } var addrows = new DataGridViewRow[selectedRows.Count]; int i = 0; foreach (DataGridViewRow src in selectedRows) { addrows[i] = new DataGridViewRow(); addrows[i].CreateCells(DisabledView); addrows[i].SetValues(src.Cells[DisabledView_Name.Index].Value); addrows[i].Cells[DisabledView_Name.Index].Tag = src.Cells[EnabledView_Name.Index].Tag; addrows[i].Tag = src.Tag; EnabledView.Rows.Remove(src); i++; } DisabledView.Rows.AddRange(addrows); DisabledView.Sort(DisabledView_Name, ListSortDirection.Ascending); }
private void ButtonRightAll_Click(object sender, EventArgs e) { var addrows = new DataGridViewRow[EnabledView.Rows.Count]; int i = 0; foreach (DataGridViewRow src in EnabledView.Rows) { addrows[i] = new DataGridViewRow(); addrows[i].CreateCells(DisabledView); addrows[i].SetValues(src.Cells[DisabledView_Name.Index].Value); addrows[i].Cells[DisabledView_Name.Index].Tag = src.Cells[EnabledView_Name.Index].Tag; addrows[i].Tag = src.Tag; i++; } EnabledView.Rows.Clear(); DisabledView.Rows.AddRange(addrows); DisabledView.Sort(DisabledView_Name, ListSortDirection.Ascending); }