作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
晚上好,我想知道在写入数据时如何更改单元格的颜色
我有这个...
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
的Color
属性。您可以通过TInplaceEdit
属性访问TStringGrid.InplaceEditor
。
我建议从TStringGrid
派生一个新组件,并重写其虚拟CreateEditor()
方法。如果您的表单中只有1个网格,那么一个简单的插入器就足够了,例如:
type
TStringGrid = class(Vcl.Grids.TStringGrid)
protected
function CreateEditor: TInplaceEdit; override;
end;
TFrmReportes = class(TForm)
SG: TStringGrid;
...
end;
...
type
TInplaceEditAccess = class(TInplaceEdit)
end;
function TStringGrid.CreateEditor: TInplaceEdit;
begin
Result := inherited CreateEditor;
TInplaceEditAccess(Result).Color := RGB(255, 119, 119);
end;
关于delphi - 在单元格中输入数据时,更改StringGrid的单元格颜色。德尔菲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59097731/
当我将鼠标移到面板上的位置时,如何显示面板上的所有内容? 当我再次将其移开时,它会淡出吗? 在可见时执行此操作不是问题(淡出除外),我可以使用onmouseleaves进行此操作。 但是当它不可见时,
晚上好,我想知道在写入数据时如何更改单元格的颜色 我有这个... procedure TFrmReportes.SGDrawCell(Sender: TObject; ACol, ARow: Inte
嗨,我有一个运行良好的应用程序Windows XP Pro、Windows Visa、Windows 7 但是当我在嵌入式 Windows XP 上运行它时,它不起作用并给出以下错误: EEncodi
我是一名优秀的程序员,十分优秀!