Announcement

Collapse
No announcement yet.

Farbe im Listview

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Farbe im Listview

    Wie kann ich denn die Subitems eines Listview-Items in Blau darstellen?
    Mit den Items habe ich das über AdvancedDrawItem hinbekommen. Aber bei AdvancedDrawSubItem klappt es irgendwie nicht.

    M.f.G. Andreas Käding

  • #2
    Hallo,
    mit einer normalen LV habe ich das mal so gemacht:
    <PRE>
    procedure TMainForm.lvDataCustomDrawSubItem(Sender: TCustomListView;
    Item: TListItem; SubItem: Integer; State: TCustomDrawState;
    var DefaultDraw: Boolean);
    var Value : single;
    begin
    if Item = nil then Exit;
    with Sender.Canvas do
    begin
    if SubItem = 7 then
    begin
    Value:= StrToFloat(Item.SubItems.Strings[6]);
    if Value < 0.0
    then begin
    Font.Style:=[fsBold];
    Font.Color:= clRed;
    end
    else begin
    Font.Style:=[];
    Font.Color:= clBlack;
    end;
    end
    else begin
    Font.Style:=[];
    Font.Color:= clBlack;
    end;
    end;

    procedure TMainForm.lvDataCustomDrawItem(Sender: TCustomListView;
    Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    begin
    // Standardeinstellung ermitteln:
    Sender.Canvas.Font.Color:= GetSysColor(COLOR_WINDOWTEXT);
    end;
    </PRE>
    Ich hoffe es hilft. Gruß Alex

    Comment

    Working...
    X