private void MoveUp_Click(object sender, RoutedEventArgs e)
{ DataRowView rowView = this.listScrip.SelectedItem as DataRowView; if (rowView == null) { return; } DataRow selRow = rowView.Row; int index = dtScrip.Rows.IndexOf(selRow); if (index == 0) { return; } DataRow newRow = dtScrip.NewRow(); newRow.ItemArray = dtScrip.Rows[index].ItemArray; dtScrip.Rows.Remove(selRow); dtScrip.Rows.InsertAt(newRow, index - 1); this.listScrip.SelectedIndex = index - 1; } private void MoveDown_Click(object sender, RoutedEventArgs e) { DataRowView rowView = this.listScrip.SelectedItem as DataRowView; if (rowView == null) { return; } DataRow selRow = rowView.Row; int index = dtScrip.Rows.IndexOf(selRow); if (index == dtScrip.Rows.Count - 1) { return; } DataRow newRow = dtScrip.NewRow(); newRow.ItemArray = dtScrip.Rows[index].ItemArray; dtScrip.Rows.Remove(selRow); dtScrip.Rows.InsertAt(newRow, index + 1); this.listScrip.SelectedIndex = index + 1; }