Registriert seit: 9. Jul 2007
Ort: Bensheim
20 Beiträge
RAD-Studio 2010 Arc
|
Re: mehrzeilige listbox-einträge
10. Okt 2008, 18:32
Zitat von hoika:
Hallo,
warum so kompliziert,
nimm einen TListView, da musst du gar nichts machen.
Delphi-Quellcode:
ListItem:= ListView.Items.Add;
ListItem.Caption:= 'Spalte 1';
ListItem.SubItems.Add('Spalte2');
Hier geht es um mehrZEILIGE ListBoxes. Nicht um mehrspaltige.
Für alle die es interessiert:
Delphi-Quellcode:
type
TCodeInsightItem = record
ciType: string[255];
ciKey: string[255];
ciAttri: string[255];
ciReturn: string[255];
ciDesc: string[255];
end;
type
PCodeInsightItem = ^TCodeInsightItem;
...........
procedure X ...;
var
ciEntry: TCodeInsightItem;
ciEntryP: PCodeInsightItem;
begin
for i := 0 to lbxCodeInsight.Items.Count - 1 do
begin
ciEntryP := PCodeInsightItem(lbxCodeInsight.Items.Objects[i]);
Dispose(ciEntryP);
end;
lbxCodeInsight.Items.Clear;
for i := 0 to intBuffer - 1 do
begin
... Definition von ciEntry ...
New(ciEntryP);
ciEntryP^.ciType := ciEntry.ciType;
ciEntryP^.ciKey := ciEntry.ciKey;
ciEntryP^.ciAttri := ciEntry.ciAttri;
ciEntryP^.ciReturn := ciEntry.ciReturn;
ciEntryP^.ciDesc := ciEntry.ciDesc;
lbxCodeInsight.Items.AddObject(ciEntryP^.ciKey, TObject(ciEntryP));
end;
end;
procedure TfrmMain.lbxCodeInsightDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Entry: PCodeInsightItem;
ciKeyWidth, ciAttriWidth: Integer;
begin
Entry := PCodeInsightItem(Items.Objects[Index]);
if ItemIndex <> Index then
if Index mod 2 = 0 then Canvas.Brush.Color := $00FDF7EE else Canvas.Brush.Color := clWhite;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+1, Rect.Top+1, Entry^.ciType);
Canvas.Font.Style := [fsBold];
Canvas.TextOut(Rect.Left+60, Rect.Top+1, Entry^.ciKey);
ciKeyWidth := Canvas.TextWidth(Entry^.ciKey);
Canvas.Font.Style := [];
Canvas.TextOut(Rect.Left+60+ciKeyWidth, Rect.Top+1, ' (' + Entry^.ciAttri + ')');
ciAttriWidth := Canvas.TextWidth(' (' + Entry^.ciAttri + ')');
if Entry^.ciReturn <> '' then Canvas.TextOut(Rect.Left+60+ciKeyWidth+ciAttriWidth, Rect.Top+1, ' : ' + Entry^.ciReturn);
Canvas.Font.Style := [fsBold];
Canvas.Font.Size := 8;
Canvas.TextOut(Rect.Left+5, Rect.Top+18, Entry^.ciDesc);
end;
end;
http://home.viathinksoft.de/victor/d...ne_listbox.jpg
|
|
Zitat
|