Filling DBGrid dynamically with related DataSource and DataSet (Delphi)

298 views Asked by At

In my project i have 1 database with 20 DataSource & DataSet. I would like to capture the customer name with "BGrid1.SelectedField.AsString;" and open another DbGrid2 with data (datasource and dataset) referring to the selected customer. In sample below is working, but i have no idea how to do changing dynamically.

procedure TMain.DBGrid1DblClick(Sender: TObject);
  begin 
   Form2.Caption := DBGrid1.SelectedField.AsString;
if DBGrid1.DataSource.DataSet.RecNo = 1 then 
begin
 DBGrid2.DataSource := Form2.DtSource05;
  DBGrid2.DataSource.DataSet := Form2.ADO01;
   Form2.Show;
end; 

Can someone help me please?

Thanks in advance.

0

There are 0 answers