cxGrid ile gösterdiğim bilgilerin her satırda farklı renkte olmasını istiyorum. Ancak bununla ilgili bir çözüm bulamadım.
Forumda ve internetteki örneklerde hep field değerine göre renk değiştiriyor. Benim istediğim 1. satır sarı, 2. satır kırmızı renk olarak sürekli devam edecek.
type
TCustomDBGridCracker = class(TCustomDBGrid);
procedure TCari_Islemler_Pen.JvDBUltimGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
If gdSelected in State Then Exit;
If JvDBUltimGrid1.DataSource.DataSet.RecNo mod 2 = 0 Then
JvDBUltimGrid1.Canvas.Brush.Color := clRed
Else
JvDBUltimGrid1.Canvas.Brush.Color := clYellow;
with TCustomDBGridCracker(JvDBUltimGrid1) Do
If DataLink.ActiveRecord = Row-1 Then
Canvas.Brush.Color := ClSkyBlue;
JvDBUltimGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
Uses cxVariants; // Eklenmesi gerekiyor
procedure TFSiparisListesi.EDTDetayViewStylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
var
I, J: Integer;
V1, V2: Variant;
begin
J := 0;
for I := 0 to ARecord.Index-1 do
begin
V1 := TcxGridTableView(Sender).ViewData.Rows[I].Values[EDTSiparisViewSiparisNo.Index];
V2 := TcxGridTableView(Sender).ViewData.Rows[I + 1].Values[EDTSiparisViewSiparisNo.Index];
if not VarEqualsExact(V1, V2) then
Inc(J);
end;
if J mod 2 = 0 then
AStyle := FMain.CXSari
else
AStyle := FMain.CXBeyaz;
end;