怎样控制StringGrid某一个单元格的背景色?
解决方案 »
- 为什么加载ActiveX 时 ,出现 Undelcared identifier ×××××
- 还有多少人是搭积木式开发的?
- Delphi调用VB写的exe程序,能不能象模态调用一个对话框一样,?也就是说主窗体此时什么也不能做,只有等这个exe关闭掉,才继续操作?
- delphi的excel输出不在同一个表中的问题,请赐教!谢谢
- 为什么时间计算有误差,怎么解决啊?
- 超级难题!关于数据库导出~~~
- 请问有什么功能比较强大的dbgrid,在下载
- 动态创建数据库?
- 学delphi到底好不好找工作
- 急急急:如何用MEDIAPLAYER播放DAT格式文件??
- table 保存不了数据
- treeview控件的data属性问题
Longint;
Rect: TRect; State: TGridDrawState);
const
cFmtCentered =DT_SINGLELINE or DT_VCENTER or DT_NOCLIP or DT_CENTER;
cFmtLeft = DT_SINGLELINE or DT_VCENTER or DT_NOCLIP or DT_LEFT;
cFmtRight = DT_SINGLELINE or DT_VCENTER or DT_NOCLIP or DT_RIGHT;
var
iFormat : integer;
begin
With StringGrid1 do
begin
Canvas.Font := Font;
Canvas.Font.Color := clRed;
iFormat := cFmtRight; if ((Col Mod 2) = 1) then
Canvas.Brush.Color := clWindow
else
Canvas.Brush.Color := clBlue; Canvas.FillRect(Rect);
Rect.Right := Rect.Right - 3;
StrPCopy(@(TempString[0]), StringGrid1.Cells[Col, Row]);
DrawText(Canvas.Handle, TempString, -1 , Rect, iFormat);
end;
end;
procedure TFrmMain.TurnSGridCellColor(CurrRow:integer;CurrCol:integer);
//改变gGrid某一行,某一列背景色
var
i:integer;
MyRect:TRect;
incTop=18;incLeft=65;incRight=65;incBottom=18;//单元格增量
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 StringGrid1.Canvas do
begin
brush.Color:=claqua;
Rectangle(MyRect.Left-1,MyRect.Top-1,MyRect.Right+1,MyRect.Bottom+1);
textout(MyRect.Left,MyRect.Top,stringgrid2.Cells[CurrCol,CurrRow]);
end;
end;
procedure TFrmMain.TurnSGridCellColor(CurrRow:integer;CurrCol:integer);//改变stringGrid某一行,某一列背景色
var
i:integer;
MyRect:TRect;
//
const incTop=18;incLeft=65;incRight=65;incBottom=18;//
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:=claqua;
Rectangle(MyRect.Left,MyRect.Top,MyRect.Right,MyRect.Bottom);
textout(MyRect.Left,MyRect.Top,stringgrid2.Cells[CurrCol,CurrRow]);
// Rectangle
end;
end;