Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: ListView Accessory item display problem


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Mindaugas Atkoc...

Posts: 4
Registered: 10/5/16
ListView Accessory item display problem  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 7, 2017 2:10 AM
Hello,
I am using a simple procedure to update listview items (DynamicAppearance), but have a problem.
I need that listview item (TAccessoryObjectAppearance, AccessoryType: Checkmark) will be shown(checked)/or not at runtime depending on the provided value.

At design time I set the Item as "not visible".

Here is the code which does not work:

procedure UpdateList(lv: TListView);
var
  Litem: TListViewItem;
  iName: TListItemText;
  iCheck: TListItemAccessory;
begin
  FDQuery.Open('SELECT Name, Value FROM tbl_values');
 
  lv.Items.Clear;
  lv.BeginUpdate;
 
  while not FDQuery.Eof do
  begin
    Litem := lv.Items.Add;
 
    iName      := Litem.Objects.FindObjectT<TListItemText>('Name');
    iName.Text := FDQuery.FieldValues['Name'];
 
    iCheck     := LItem.Objects.FindObjectT<TListItemAccessory>('Check');
    if FDQuery.FieldValues['Value'] > 0 then
      iCheck.Visible:= True
    else
      iCheck.Visible := False;
 
    FDQuery.Next;
  end;
 
  lv.EndUpdate;
end;

This procedure runs on form.show event.

But then I run another procedure which changes some values in the database table and runs the same procedure (UpdateList) again to update listview item values. And now Checkmarks are showed correctly.

What I am doing wrong?

Delphi 10.2.1

Edited by: Mindaugas Atkociunas on Dec 7, 2017 2:11 AM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02