Jak zmienić kolor lub styl jednego Itema w TListView przy ViewStyle VSReport?
0
0
Nie wiem czy dokładnie o to Ci chodziło al metodą na ustawianie różnych właściwości jest
Listview.Selected
Tam masz dowyboru wszystkie właściwości i funkce komponentu TListview (chyba wszstkie ;) )Dla przykładu zmienianie koloru to
Listview.Selected.ListView.Brush.Color := clred
//możesz też zamiast koloru np. ustawić
//bitmapę na tło(~.bitmap)
Pisałem z pamięci więc jakby coś nie ten to napisz.
Mam nadzieję że zadziała.
// dopisane
Nie wiem czemu powtarza słówko bitmapę na tło ale cóż (przy pisaniu jest tylko raz), ale cóż to chyba wina serwera
0
Chyba Rabbitsoft napisałeś od rzeczy.
Do tego służą zdarzenia:
OnCustomDrawItem i OnCustomDrawSubitem
przykłady: (z mojego programu)
procedure TFormMain.ListViewSessionsCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
//an important marker is stored as Item.
begin
ListViewSessions.Canvas.Font.Color:=
FormSetup.ShapeImportantMarkers.Brush.Color;
end;
procedure TFormMain.ListViewSessionsCustomDrawSubItem(
Sender: TCustomListView; Item: TListItem; SubItem: Integer;
State: TCustomDrawState; var DefaultDraw: Boolean);
//displays session fields in appropriate colors
var
LColor: TColor;
LStyle: TFontStyles;
begin
LColor:=clWindowText;
LStyle:=[];
//neutral colors
if (SubItem=16) and (StrToFloatDef(Item.SubItems[15],-1)>=80) then
LColor:=FormSetup.ShapeOutcome80.Brush.Color;
// outcome >=80%
if (SubItem=16) and (StrToFloatDef(Item.SubItems[15],-1)>=90) then
LColor:=FormSetup.ShapeOutcome90.Brush.Color;
//outcome >=90%
if (SubItem=17) and (StrToIntDef(Item.SubItems[16],-1)>0) then
LColor:=FormSetup.ShapeCorrectionsW.Brush.Color;
// if corrections after wrong response >0
if (SubItem=18) and (StrToFloatDef(Item.SubItems[17],1e6)<=27) then
LColor:=FormSetup.ShapeSignificantU.Brush.Color;
//Mann-Whitney significance in Konorski's task
if Item.SubItems[6]<>'' then
LColor:=FormSetup.ShapeCancelledSessions.Brush.Color;
//cancelled sessions
if (SubItem=7) or (SubItem=1) or (SubItem=2) or(SubItem=4) then
LColor:=FormSetup.ShapeImportantMarkers.Brush.Color;
//important markers
if Item.SubItems[8]='EVENT' then
LColor:=FormSetup.ShapeEvent.Brush.Color;
//whole Event is dispalyed in a different color
with ListViewSessions.Canvas do
begin
Font.Color:=LColor;
Font.Style:=LStyle;
end;
//apply colors
end; //TFormMain.ListViewSessionsCustomDrawSubItem