How to read value of TcxLookupComboBox when looping cxGrid?

286 Views Asked by At

I have cxGrid that has a column with TcxLookupComboBox type linked with DataSource

I need to read the value of the TcxLookupComboBox fields of each row in the cxGrid

I want a code of loop when I can read the data of TcxLookupComboBox if spedific column in cxGrid

Thank you

1

There are 1 best solutions below

1
Fabrizio On

You can iterate through the grid's records and get the values assumed by a column using the DataController's Values or DisplayTexts properties as follows:

var
  i : Integer;
  View : TcxGridDBTableView;
  Col : TcxGridColumn;
begin
  View := <the gridview, for example cxGridDBTableView1>;
  Col := <the column you want to get the value>;

  i := 0;
  while(i < View.DataController.RecordCount) do
  begin
    ShowMessage(
       'Record index = ' + IntToStr(i) + sLineBreak + 
       'Value = ' + VarToStr(View.DataController.Values[i, Col.Index]) + sLineBreak + 
       'DisplayValue = ' + VarToStr(View.DataController.DisplayTexts[i, Col.Index])
    );
    Inc(i);
  end;
end;