晚上好,我想知道在向其中写入数据时如何更改单元格的颜色
我有这个...
procedure TFrmReportes.SGDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (gdSelected in State) then
begin
SG.Canvas.Brush.Color := rgb(255,119,119);
SG.Canvas.FillRect(SG.CellRect(ACol, ARow));
SG.Canvas.TextOut(Rect.Left+2,Rect.Top+2, SG.Cells[ACol, ARow]);
end;
end;
但是在单元格中输入数据时,它变成白色
再次感谢!!
TStringGrid
在当前正在编辑的单元格顶部显示TInplaceEdit
。 TInplaceEdit
覆盖整个单元格。这就是为什么您看不到自定义工程图的原因。您将需要更改TInplaceEdit
的TInplaceEdit
属性。您可以通过Color
属性访问TInplaceEdit
。
我建议从TStringGrid.InplaceEditor
派生一个新组件,并覆盖其虚拟TStringGrid.InplaceEditor
方法。如果您的表单中只有1个网格,那么一个简单的插入器就足够了,例如:]
TStringGrid