Welcome

Welcome, thanks to look my blog

Wednesday 16 April 2014

Dbgrid Berwarna di delphi 7


procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
Image : TBitmap;
begin
Image := TBitmap.Create;
try
with Image do
begin
Transparent := True;
TransparentColor := Image.Canvas.Brush.Color;
TransparentMode := tmFixed;
end;
if ZTable1.RecNo > 0 then
begin
if Column.Title.Caption = 'stok' then
begin
//Dibawah Minimal
if ZTable1.FieldByName('stok').AsInteger < ZTable1.FieldByName('Stok_Minimal').AsInteger then
begin
Image.LoadFromFile(ExtractFilePath(Application.ExeName)+'Fall.bmp');
DBGrid1.Canvas.Draw(Rect.Left+2, Rect.Top+2, Image);
end;
//Normal
if (ZTable1.FieldByName('stok').AsInteger >= ZTable1.FieldByName('Stok_Minimal').AsInteger) AND
(ZTable1.FieldByName('stok').AsInteger <= ZTable1.FieldByName('Stok_Maksimal').AsInteger) then
begin
Image.LoadFromFile(ExtractFilePath(Application.ExeName)+'Forward.bmp');
DBGrid1.Canvas.Draw(Rect.Left+2, Rect.Top+2, Image);
end;
//Diatas Maksimal
if ZTable1.FieldByName('stok').AsInteger > ZTable1.FieldByName('Stok_Maksimal').AsInteger then
begin
Image.LoadFromFile(ExtractFilePath(Application.ExeName)+'Raise.bmp');
DBGrid1.Canvas.Draw(Rect.Left+2, Rect.Top+2, Image);
end;
end;
end;
finally
end;
end;

end.



 



No comments:

Post a Comment