Ton*_*lff 1 delphi inheritance tstringgrid
在 Delphi 中,如何创建从 TStringGrid 类派生的类,以便与网格单元关联的 TObject 数组具有更具体的类型,例如用于指定单元格颜色的 TColor?
type
TStringColorGrid = class(TStringGrid)
private
function GetColor(ACol, ARow: Integer): TColor;
procedure SetColor(ACol, ARow: Integer; AValue: TColor);
public
property Colors[ACol, ARow: Integer]: TColor read GetColor write SetColor;
end;
function TStringColorGrid.GetColor(ACol, ARow: Integer): TColor;
begin
Result := TColor(inherited Objects[ACol, ARow]);
end;
procedure TStringColorGrid.SetColor(ACol, ARow: Integer; AValue: TColor);
begin
inherited Objects[ACol, ARow] := TObject(AValue);
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
115 次 |
| 最近记录: |