設定GridView中的【OptionsSelection】->【MultiSelectMode】設定為CheckBoxRowSelect.
設定GridView中的【OptionsSelection】->【MultiSelect】設定為true;
最後通過int[] RowHandle=GridView.GetSelectRows();擷取選中行的行号。然後根據自己的需要進行處理。
int id = Convert.ToInt32(gridView1.GetRowCellValue(index, "id"));
int[] RowHandle = gridView1.GetSelectedRows();
DataTable nn=gridControl1.DataSource as DataTable;
string nns = string.Empty;
foreach (int item in RowHandle.ToList())
{
nns += " 姓名: " + nn.Rows[item]["Name"].ToString();
}
XtraMessageBox.Show($"選中的人:{nns}");