iyi günler daha önce DBGrid'in istenen satırını renklendirmeyi sormuştum bana
dataset içindeki bir bilgiye göre;
DrawColumnCell
if DbGrid3.DataSource.DataSet.FieldByName('print').Value = 't' then
begin // irsaliye yazdırılmış ise skyblue renkte
DbGrid3.Canvas.Font.Color := clNavy;
DbGrid3.Canvas.Brush.Color := clSkyBlue;
DbGrid3.Canvas.FillRect(Rect);
DbGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
kayıt no.suna göre
DrawDataCell
if odd(DBGrid1.DataSource.DataSet.RecNo) then
DBGrid1.Canvas.Brush.Color := clWhite
else
DBGrid1.Canvas.Brush.Color := clSkyBlue;
DBGrid1.DefaultDrawDataCell(Rect, Field, State);
bu kodları gönderdiniz çok teşekkür ediyorum ama
DbGrid3.Canvas.FillRect(Rect);
DbGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
bu satırlarda
Rect ve DefaultDrawColumnCell(Rect, DataCol, Column, State);
Rect, datacol, column, state nedir bir kısmını çözemedim
örneklendirirseniz ve açıklarsanız sevinirim ilgilendiğiniz için teşekkürler..
DBGrid renklendirme hakkında 2
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Kod: Tümünü seç
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if DbGrid3.DataSource.DataSet.FieldByName('print').Value = 't' then
begin // irsaliye yazdırılmış ise skyblue renkte
DbGrid3.Canvas.Font.Color := clNavy;
DbGrid3.Canvas.Brush.Color := clSkyBlue;
DbGrid3.Canvas.FillRect(Rect);
DbGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
Kod: Tümünü seç
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if odd(DBGrid1.DataSource.DataSet.RecNo) then
DBGrid1.Canvas.Brush.Color := clWhite
else
DBGrid1.Canvas.Brush.Color := clSkyBlue;
DBGrid1.DefaultDrawDataCell(Rect, Field, State);
end;
const ifadesinden de anlaşılacağı gibi sabittirler.
dbgrid in hangi satırını renklendireceğini anladığı sabitler
yanlış biliyorsam düzeltin;
rect = rectangle den geliyor, satırdaki her bir hücre,
column dbgrid deki kolon,
field dataset deki alan,
state de dateset in durumu (Edit, Insert)
sanıyorum bu şekilde..
kolaygelsin..