我想问下,DrawCell 事件是什么意思,好像是什么自绘制, 请问这个事件只有 stringgrid 有吗?像我想改变一个stringgrid 已知坐标 的单元格的 字符串 颜色 怎么实现? 还有里面的属性具体怎么用 的 谁有这方面的 资料 给我说下谢谢, 最好 基础点的!
解决方案 »
- 封装在bpl里的ado提示:missing connection or connecttionstring
- 怎么屏蔽Ctrl+V?
- 愁工作啊
- 我是个delphi生手,请问你们.....
- HP 5L打印机在win2000server下面安装后,怎么就不能使用呢?
- 如何开始Delphi.Net的编程?
- 加急!!!!请问如何动态建立 Access(*.mdb) 的odbc数据源(User Dsn)
- 各位大哥 ,谁知道<<delphi 5开发人员指南>>的配套光盘在哪下载??
- 100 分求中文朗读组件,分不够可以再加。
- 如何把已有的几个网址替换到IE的地址栏中
- 关于delphi下操作内存流(tmemorystream)
- 元旦快乐+新年快乐
ListBox
ComBoBox都有类似的自绘事件但我对StringGrid也不熟悉--->
感觉应该是用ACol, ARow: Integer来判断坐标所在的单元格
通过Rect设置画布范围
Cnvs := (Control as Tstringgrid).Canvas;
Cnvs.Brush.Color := clSkyBlue;
Cnvs.Pen.Color := clNavy;大致应该是用到这些代码吧
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with Sender as TStringGrid do begin
if (ARow mod 2 =0) then begin //当行为偶数色为
Canvas.Brush.Color := clBtnFace;//画布颜色
Canvas.font.Color:=clblack;//字体色
end
else
begin
Canvas.Brush.Color := clgreen;
Canvas.font.Color := clWhite;
end;
Canvas.FillRect(Rect);
canvas.textout(rect.Left,rect.Top,cells[Acol,ARow]);
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0] := '姓名';
StringGrid1.Cells[1,0] := '学号';
StringGrid1.Cells[2,0] := '班级';
StringGrid1.Cells[3,0] := '课程';
StringGrid1.Cells[4,0] := '分数';
StringGrid1.Cells[0,1] := '张三';
StringGrid1.Cells[1,1] := '001';
StringGrid1.Cells[2,1] := '高三一班';
StringGrid1.Cells[3,1] := '语文';
StringGrid1.Cells[4,1] := '9';
StringGrid1.Cells[0,2] := '李四';
StringGrid1.Cells[1,2] := '002';
StringGrid1.Cells[2,2] := '高三二班';
StringGrid1.Cells[3,2] := '数学';
StringGrid1.Cells[4,2] := '99';
StringGrid1.Cells[0,3] := '王五';
StringGrid1.Cells[1,3] := '001';
StringGrid1.Cells[2,3] := '高三一班';
StringGrid1.Cells[3,3] := '数学';
StringGrid1.Cells[4,3] := '19';
end;网上很多的呀