0

I want to show a list with TListView, generated with data out of my database. But my code is only showing one item in the list.

It should look like a short List with Text like Address, Name1, Name1 just like on this picture:

image

The Code for the view on the pic:

procedure TForm2.RefreshButton1Click(Sender: TObject); 
var
 queryListClient : TFDQuery;
 ItemAdd : TListViewItem;
begin
  queryListClient := TFDQuery.Create(Nil);
  queryListClient.Connection := FDConnection1;

  queryListClient.SQL.Clear;
  queryListClient.SQL.Add('Select * from Projekt ORDER by ProjNr');
  queryListClient.Open();
  queryListClient.First;

  List_Clients1.Items.Clear;
  List_Clients1.BeginUpdate;
  while Not queryListClient.Eof do
  begin
    ItemAdd := List_Clients1.Items.Add;
    ItemAdd.Text := queryListClient.FieldByName('Name1').AsString;
    ItemAdd.Detail := queryListClient.FieldByName('Name2').AsString;
    queryListClient.Next;
  end;
  List_Clients1.EndUpdate;
  queryListClient.Close;
  queryListClient.Free;
end;

What it looks like now:

What it looks like now

Ken White
  • 123,280
  • 14
  • 225
  • 444
J1MAV1GN0N
  • 33
  • 2
  • 6
  • 1
    Besides other issues in your code, the only reason this could happen is if that query really only returns one record. What happens when you execute it directly on your database using a query tool? Do you really have more than one record in this table? – Jerry Dodge Sep 12 '17 at 18:11
  • See `\Users\Public\Documents\Embarcadero\Studio\19.0\Samples\Object Pascal\Multi-Device Samples\User Interface\ListView\ListViewMultiDetailAppearance\ListViewMultiDetailAppearance.dproj` demo. – Victoria Sep 12 '17 at 18:29
  • Which question do you want an answer to, by the way? How to style your control to look like the first screenshot? Or why you're only getting one item in your list? – Jerry Dodge Sep 12 '17 at 19:58
  • Or if you want a single detail (the picture shows multiple) as your code tries to add, follow `\Users\Public\Documents\Embarcadero\Studio\19.0\Samples\Object Pascal\Multi-Device Samples\User Interface\ListView\ListViewCustomBottomDetail\SampleListViewCustomBottomDetailProject.dproj` demo. – Victoria Sep 12 '17 at 21:26

1 Answers1

0

You probably did not link the listview SYNC property to your dataset (LiveBindings Designer).enter image description here