我用StringGrid做了一个数据录入表格,其中需要控制某些Cells[i,j]的背景颜色,以及动态确定该单元格是否可编辑的属性。
恳请各位指教,应该通过StringGrid的什么属性来加以设置。我经常查看帮助,但没有准确及时找到,还请高人授之以渔。
在此先行谢过。
恳请各位指教,应该通过StringGrid的什么属性来加以设置。我经常查看帮助,但没有准确及时找到,还请高人授之以渔。
在此先行谢过。
调试欢乐多
ARow: Integer; var CanSelect: Boolean);
begin
if (ACol<=6) and (ARow<=5) then begin
if not (goEditing in StringGrid1.Options) then
StringGrid1.Options:=StringGrid1.Options+[goEditing];
//动态确定该单元格是否可编辑的属性
end
else begin
if (goEditing in StringGrid1.Options) then
StringGrid1.Options:=StringGrid1.Options-[goEditing];
end;
end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if ARow>0 then begin
if ARow mod 2 = 0 then
StringGrid1.Canvas.Brush.Color := $00DBDBDB
//控制某些Cells[i,j]的背景颜色
else
StringGrid1.Canvas.Brush.Color := clWhite;
StringGrid1.Canvas.TextRect(Rect,Rect.Left,Rect.Top,StringGrid1.Cells[ACol,ARow]);
end;
end;