Recent Posts
Selamat datang di Coding Delphi Land Weblog kumpulan source code pemogram delphi
(Bukan maksud untuk menggurui tetapi marilah kita berbagi ilmu tuk perkembangan kemajuan teknologi kita
Minggu, 15 November 2009
Coloring TDBGrid
procedure TForm1.ColorGrid(dbgIn: TDBGrid; qryIn: TQuery; const Rect: TRect;
DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var
iValue: LongInt;
begin
if (DataCol = 0) then
begin
iValue := qryIn.FieldByName('HINWEIS_COLOR').AsInteger;
case iValue of
1: dbgIn.Canvas.Brush.Color := clGreen;
2: dbgIn.Canvas.Brush.Color := clLime;
3: dbgIn.Canvas.Brush.Color := clYellow;
4: dbgIn.Canvas.Brush.Color := clRed;
end;
dbgIn.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
ColorGrid(DBGrid1, Query1, Rect, DataCol, Column, State);
end;
DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var
iValue: LongInt;
begin
if (DataCol = 0) then
begin
iValue := qryIn.FieldByName('HINWEIS_COLOR').AsInteger;
case iValue of
1: dbgIn.Canvas.Brush.Color := clGreen;
2: dbgIn.Canvas.Brush.Color := clLime;
3: dbgIn.Canvas.Brush.Color := clYellow;
4: dbgIn.Canvas.Brush.Color := clRed;
end;
dbgIn.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
ColorGrid(DBGrid1, Query1, Rect, DataCol, Column, State);
end;
0 komentar:
Posting Komentar