cxListView和dbgrid联动

procedure TForm1.FormCreate(Sender: TObject);
begin
  ClientDataSet1.First;
  while not ClientDataSet1.Eof do
  begin
    with cxListView1.Items.Add do
    begin
      caption := ClientDataSet1.Fields[0].AsString;
      SubItems.Add(ClientDataSet1.Fields[1].asstring);
    end;
    ClientDataSet1.Next;
  end;

  ClientDataSet2.Data := ClientDataSet1.Data;
  ClientDataSet2.Close;
end;

procedure TForm1.cxListView1DblClick(Sender: TObject);
begin
  ClientDataSet2.Filter := 'CustNo=' + cxListView1.Items[cxListView1.ItemIndex].Caption;
  ClientDataSet2.Filtered := True;
  ClientDataSet2.Open;
end;

 

posted @ 2016-06-16 11:58  liessay  阅读(543)  评论(0编辑  收藏  举报