首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

关于DrawCell的有关问题

2012-02-11 
关于DrawCell的问题!我想问下,DrawCell 事件是什么意思,好像是什么自绘制, 请问这个事件只有 stringgrid

关于DrawCell的问题!
我想问下,DrawCell 事件是什么意思,好像是什么自绘制, 请问这个事件只有 stringgrid 有吗?像我想改变一个stringgrid 已知坐标 的单元格的 字符串 颜色 怎么实现? 还有里面的属性具体怎么用 的 谁有这方面的 资料 给我说下谢谢, 最好 基础点的!

[解决办法]

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;

网上很多的呀

热点排行