使用STRINGGRID中使用不同的颜色 procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin // if gdSelected in state then exit;with StringGrid1.canvas do beginif gdselected in state then beginbrush.color:=clBackground;Rectangle(Rect.Left-1, Rect.Top-1, Rect.Right+1, Rect.Bottom+1); textout(rect.left,rect.top,stringgrid1.cells[acol,arow]); exit; end; if (arow=0) then//brush.color:=clScrollBar beginbrush.color:=clmenu; pen.color:=clblack; Rectangle(Rect.Left-1, Rect.Top-1, Rect.Right+1, Rect.Bottom+1); textout(rect.left,rect.top,stringgrid1.cells[acol,arow]); exit; end else begin //pen.color:=$00EBEBEB; if (arow mod 2)=0 then begin brush.color:=$00EEEEEE; pen.color:=$00EEEEEE; end else begin brush.color:=$00F5F5EB; pen.color:= $00F5F5EB; end; end;Rectangle(Rect.Left-1, Rect.Top-1, Rect.Right+1, Rect.Bottom+1); //pen.color:=clblack;textout(rect.left,rect.top,stringgrid1.cells[acol,arow]);end; end;
给你启发!
你那个DBGRID点,菜单上有个与EDITER有关的!
然后添加列!
改变列的COLOR,然后对应添加!列对应的字段!
就ok了!
我现在没有BCB,只能这么给你说了!
希望能给你启发!
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
// if gdSelected in state then exit;with StringGrid1.canvas do beginif gdselected in state then
beginbrush.color:=clBackground;Rectangle(Rect.Left-1, Rect.Top-1, Rect.Right+1, Rect.Bottom+1);
textout(rect.left,rect.top,stringgrid1.cells[acol,arow]);
exit;
end;
if (arow=0) then//brush.color:=clScrollBar
beginbrush.color:=clmenu;
pen.color:=clblack;
Rectangle(Rect.Left-1, Rect.Top-1, Rect.Right+1, Rect.Bottom+1);
textout(rect.left,rect.top,stringgrid1.cells[acol,arow]);
exit;
end
else
begin
//pen.color:=$00EBEBEB;
if (arow mod 2)=0 then
begin
brush.color:=$00EEEEEE;
pen.color:=$00EEEEEE;
end
else
begin
brush.color:=$00F5F5EB;
pen.color:= $00F5F5EB;
end;
end;Rectangle(Rect.Left-1, Rect.Top-1, Rect.Right+1, Rect.Bottom+1);
//pen.color:=clblack;textout(rect.left,rect.top,stringgrid1.cells[acol,arow]);end;
end;