1.遍历Grid的DataController,获取所有被选择的行。
2.遍历每个被选择的行,获取每个单元格的值。
以下是示例代码:
procedure TForm1.Button1Click(Sender: TObject);
var
ASelectedRows: TcxSelection;
ARow: TcxCustomGridRow;
AColumn: TcxCustomGridTableItem;
AValue: Variant;
i, j: Integer;
begin
ASelectedRows := cxGrid1.DataController.GetSelectedRows;
for i := 0 to ASelectedRows.Count - 1 do
begin
ARow := ASelectedRows[i];
for j := 0 to cxGrid1.Levels[0].ColumnCount - 1 do
begin
AColumn := cxGrid1.Levels[0].Columns[j];
AValue := cxGrid1.DataController.Values[ARow.Index, AColumn.Index];
// do something with the value
end;
end;
end;