Listview mit DynamicAppearance mit AccessoryObject
Liste der Anhänge anzeigen (Anzahl: 2)
Hallo Zusammen,
Ich habe eine ListView mit Daten gefüllt. Die Items sind DynamicAppearances mit TextObject und AccessoryObject. Das AccessoryObject ist beim erstellen AccessoryType Detail. Beim Anklicken des AccessoryObject ändert sich der AccessoryType in Checkmark, beim nochmal Klicken wieder zurück in Detail. Das klappt auch. Aber wenn ich aber mit der Maus die Form1 ändere, ändert sich der AccessoryType in Detail. Komisch ist, ich ändere beim Klick gleichzeitig Fontfarbe und Fontaussehen des Textes. Das bleibt aber.
Delphi-Quellcode:
Wie kann ich das machen, dass auch der AccessoryType bleibt?
procedure TForm1.ListView1ItemClickEx(const Sender: TObject; ItemIndex: Integer;
const LocalClickPos: TPointF; const ItemObject: TListItemDrawable); begin if ItemObject is TListItemAccessory then begin ListView1.Items.SetChecked(ItemIndex, not ListView1.Items[ItemIndex].Checked); end; UpdateItem; end; procedure TForm1.UpdateItem; var AAccessory : TListItemAccessory; AListItemText : TListItemText; begin AAccessory := ListView1.Items[ListView1.ItemIndex].Objects.FindObjectT<TListItemAccessory>('Accessory2'); if Assigned(AAccessory) then if ListView1.Items[ListView1.ItemIndex].Checked then begin AAccessory.AccessoryType := TaccessoryType.Checkmark; end else begin AAccessory.AccessoryType := TaccessoryType.Detail; end; AListItemText:=ListView1.Items[ListView1.ItemIndex].Objects.FindObjectT<TListItemText>('Text3'); if Assigned(AListItemText) then if ListView1.Items[ListView1.ItemIndex].Checked then begin AListItemText.Font.Style:=[TFontStyle.fsBold,TFontStyle.fsUnderline,TFontStyle.fsItalic]; AListItemText.TextColor := TAlphaColor($FFFF4500); end else begin AListItemText.Font.Style:=[]; AListItemText.TextColor := TAlphaColor($FF000000); end; end; Ach ja, Delphi 10.4.2. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:27 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz