//hsr
검색해보시면 많아요 예로 "ListView에서 '열(col)'에 칼라를 주고싶어요"
ListView의 속성 OwnerDraw를 True하세요
아래예는 아이템이 'aaa'이면 서브아이템도 노란색바탕에 Bold로 글자를 씁니다.
procedure TForm1.ListView1DrawItem(Sender: TCustomListView;
Item: TListItem; Rect: TRect; State: TOwnerDrawState);
var
i,j, ColPos: Integer;
ColRect : TRect;
begin
with ListView1 do begin
if Item.Caption = 'aaa' then begin
Canvas.Brush.Color := clYellow;
Canvas.FillRect(Rect);
Canvas.Font.Style := [fsBold];
end;
Canvas.TextOut(Rect.Left, Rect.Top, Item.Caption);
for i := 0 to Item.SubItems.Count-1 do begin
ColPos := 0;
for j := 0 to i do
ColPos := ColPos + Columns[j].Width;
ColRect := Rect;
ColRect.Left := Rect.Left+ColPos;
if Item.Caption = 'aaa' then begin
Canvas.Brush.Color := clYellow;
Canvas.FillRect(ColRect);
Canvas.Font.Style := [fsBold];
end;
Canvas.TextOut(ColRect.Left, ColRect.Top, Item.SubItems[i]);
end;
end;
end;
//hsr
검색해보시면 많아요 예로 "ListView에서 '열(col)'에 칼라를 주고싶어요"
ListView의 속성 OwnerDraw를 True하세요
아래예는 아이템이 'aaa'이면 서브아이템도 노란색바탕에 Bold로 글자를 씁니다.
procedure TForm1.ListView1DrawItem(Sender: TCustomListView;
Item: TListItem; Rect: TRect; State: TOwnerDrawState);
var
i,j, ColPos: Integer;
ColRect : TRect;
begin
with ListView1 do begin
if Item.Caption = 'aaa' then begin
Canvas.Brush.Color := clYellow;
Canvas.FillRect(Rect);
Canvas.Font.Style := [fsBold];
end;
Canvas.TextOut(Rect.Left, Rect.Top, Item.Caption);
for i := 0 to Item.SubItems.Count-1 do begin
ColPos := 0;
for j := 0 to i do
ColPos := ColPos + Columns[j].Width;
ColRect := Rect;
ColRect.Left := Rect.Left+ColPos;
if Item.Caption = 'aaa' then begin
Canvas.Brush.Color := clYellow;
Canvas.FillRect(ColRect);
Canvas.Font.Style := [fsBold];
end;
Canvas.TextOut(ColRect.Left, ColRect.Top, Item.SubItems[i]);
end;
end;
end;