![]() |
Listbox - OnMeasureItem kann nicht auf Objekt zugreifen
Im Ereignis OnMeasureItem kann in einer ListBox nach dem
Hinzufügen eines neuen Items (invl. Objekt, z.B. einer Bitmap) nicht auf das Objekt zugegriffen werden. Mir hilfreich war ![]() ![]() Zitat:
Delphi-Quellcode:
// Aufruf z.B. nach aListbox.Add
// => ListBoxRefreshItem(aListBox, aListBox.Items.Count-1); // oder aListBox.Items.Move(oldPos, newPos); // => ListBoxRefreshItem(aListBox, newPos); procedure TXYZ.ListBoxRefreshItem(Control: TWinControl; index: integer); var lb: TListBox; H: integer; begin lb := TListBox(Control); if lb.Style = lbStandard then exit; ListBoxMeasureItem(lb, index, H); // Siehe unten lb.Perform (LB_SETITEMHEIGHT, index, MAKELPARAM(H, 0)); lb.refresh; end;
Delphi-Quellcode:
procedure THeavyLiftEditDlg.ListBoxMeasureItem(Control: TWinControl; Index:
Integer; var Height: Integer); var lb: TListbox; Bitmap: TBitmap; begin if Index = -1 then exit; lb := TListBox(Control); Bitmap:= TBitmap( lb.Items.Objects[Index] ) // Measure hight according to available subitem entries. with lb.Canvas do begin // Measure height sample Font.Style := [fsBold]; Height := TextHeight('Wg') + 2 ; Height := Bitmap.Height; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:30 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz