当前位置:主页>仓库管理软件> 列表

怎样改变stinggrid单元格的输入背景颜色? 找实用的财务软件

记账软件版1楼: stringgrid 单元格颜色在输入时总是白的,能不能变成其它颜色?

2楼: procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with StringGrid1.Canvas do
begin
if ACol = 0 then
Brush.Color := clred
else if ARow = 0 then
Brush.Color := clBlue
else
// Brush.Color := clyellow;
FillRect(Rect);
TextRect(Rect, rect.left+1, rect.top+1, ''Test'');
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
MyRect: TGridRect;
Rect: TRect;
begin
MyRect := StringGrid1.Selection;

StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.FillRect(TRect(MyRect));
end; 如实用的财务软件

3楼: TStringGrid/TDrawGrid 都是从 TCustomGrid 继承来的, TCustomGrid 有一个
InplaceEditor 属性(protected)是从TCustomEdit继承来的, TCustomEdit 具有
你所要的功能。
由于 InplaceEditor 是一个保护属性,故不能在 StringGrid 中使用它。如果在我
们的程序中从 TCustomGrid 继承一个 TMyGrid,并将 InplaceEditor 属性说明成
published 就可以直接使用它了。

4楼: 多谢SmallGhost兄!!如何更改?

5楼: 我上面已给出绘制颜色的方法
如按SmallGhost所说
你直接在TCustomEdit中把InplaceEditor属性从protected
改到public ,然后重新编译
或者自己写个控件从TCustomGrid继承,可按TStringGrid写
然后把上述属性公布出来即可

6楼: to:uiit兄:
如果按你说的绘制颜色的方法办法,虽然焦点颜色变了,但是输入时还是白色的.

记账软件版7楼: InplaceEditor属性,能改变编辑单元格的背景色吗?
怎么改变呢?

8楼: 我将InplaceEditor属性从protected
改到publiced ,重新编译后,stringgrid 出现了InplaceEditor属性,然后怎么改变颜色呢?
求那位大侠帮助我改造stringgrid 使其能单元格颜色在输入时变成其它颜色.
多谢!!!