如果dgOutImage.DataSource=集合(RecFileArgs)
(向上移动)
dgOutImage.DataSource = new BindingList(RecFileArgs1);
//如果选择的是多行
if (dgOutImage.SelectedRows.Count > 1)
{
return;
}
dgOutImage.Focus();
//目前选择的行号
int rowIndex = dgOutImage.CurrentRow.Index;
if (rowIndex != 0)
{
RecFileArgs _reccCurr = dvrPlayListRight[rowIndex];
RecFileArgs _reccPer = dvrPlayListRight[rowIndex - 1];
dvrPlayListRight[rowIndex] = _reccPer;
dvrPlayListRight[rowIndex - 1] = _reccCurr;
dgOutImage.DataSource = dvrPlayListRight;
dgOutImage.Refresh();
dgOutImage.Rows[rowIndex - 1].Selected = true;
dgOutImage.CurrentCell = dgOutImage.Rows[rowIndex - 1].Cells[0];
}
if (rowIndex - 1 == 0)
{
向上按钮.Enabled = false;
}
else
{
向上按钮.Enabled = true;
}
2) 如果dgOutImage.DataSource= DataTable
(向下移动)
object[] _rowData = DataTable.Rows[i].ItemArray;
DataTable.Rows[i].ItemArray = DataTable.Rows[i+1].ItemArray
DataTable.Rows[i+1].ItemArray = _rowData;
DataGridView行的上下移动
最新推荐文章于 2022-06-21 16:32:01 发布