procedure TFrmMain.TurnSGridCellColor(CurrRow:integer;CurrCol:integer;WantColor:TColor);//改变stringGrid某一行,某一列背景色
var
i:integer;
MyRect:TRect;
const incTop=18;incLeft=65;incRight=65;incBottom=18;//假定单元格宽度为64,高度为17
begin
//填充MyRect
MyRect.Left:=CurrCol*incLeft;
MyRect.Top:=CurrRow*incTop;
MyRect.Right:=64+CurrCol*incRight;
MyRect.Bottom:=17+CurrRow*incBottom;
MyRect.TopLeft.X:=MyRect.Left;
MyRect.TopLeft.Y:=MyRect.Top;
MyRect.BottomRight.X:=MyRect.Right;
MyRect.BottomRight.Y:=MyRect.Bottom;
//填充颜色
with StringGrid2.Canvas do
begin
brush.Color:=WantColor;
Rectangle(MyRect.Left,MyRect.Top,MyRect.Right,MyRect.Bottom);
textout(MyRect.Left,MyRect.Top,stringgrid2.Cells[CurrCol,CurrRow]);
end;
end;
var
i:integer;
MyRect:TRect;
const incTop=18;incLeft=65;incRight=65;incBottom=18;//假定单元格宽度为64,高度为17
begin
//填充MyRect
MyRect.Left:=CurrCol*incLeft;
MyRect.Top:=CurrRow*incTop;
MyRect.Right:=64+CurrCol*incRight;
MyRect.Bottom:=17+CurrRow*incBottom;
MyRect.TopLeft.X:=MyRect.Left;
MyRect.TopLeft.Y:=MyRect.Top;
MyRect.BottomRight.X:=MyRect.Right;
MyRect.BottomRight.Y:=MyRect.Bottom;
//填充颜色
with StringGrid2.Canvas do
begin
brush.Color:=WantColor;
Rectangle(MyRect.Left,MyRect.Top,MyRect.Right,MyRect.Bottom);
textout(MyRect.Left,MyRect.Top,stringgrid2.Cells[CurrCol,CurrRow]);
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货