M
mylemontree
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在DBGRID中用不同的颜色表示事件不同的状态,如
procedure TfrmMainForm.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
frmDataModule.tblCaseState.first;
while Not frmDataModule.tblCaseState.EOF DO
BEGIN
CaseState:=frmDataModule.tblCaseState.Fieldbyname('CaseState').AsInteger;
case CaseState of
0:
begin
DBGrid1.Canvas.Font.Color:=clred;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
1:
begin
DBGrid1.Canvas.Font.Color:=clBlue;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
2:
begin
DBGrid1.Canvas.Font.Color:=clgreen;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
END;
frmDataModule.tblCaseState.NEXT;
end;
end;
进入死循环,怎么班是不是DrawColumnCell中不能加循环语句,那么我的想法应该怎么
实现?