有一个组件StringGrid1,它有一个事件
StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect;
State: TGridDrawState);
Vcl.Grids.TGridDrawState中描述了它的“ State ”参数。
我也在程序中使用了EhLib库,它的声明(GridsEh)当然位于Vcl.Grids之后。因此,这个事件当然不能正常工作,它从“ GridsEh ”(GridEh.TGridDrawState)获取数据。
然后我专门写了路径:
过程 TFMain.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: Vcl.Grids.TGridDrawState );
但是上线了
if gdFixed in State then
同样,现在弹出一个错误:
E2008 不兼容类型
我究竟做错了什么?
一般来说, ORIGINAL过程如下所示:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Format : Word;
s : string;
begin
with Sender as TStringGrid do
if gdFixed in State then
begin
if ACol < FHeaders.Count then
s := FHeaders[ACol];
Format := DT_LEFT or DT_WORDBREAK;
OffsetRect(Rect, 2, 2);
DrawText(Canvas.Handle, s, Length(s), Rect, Format);
end;
end;
虽然它
EhLib从未使用过,但我认为应该指定它if gdFixed in State then:
if Vcl.Grids.gdFixed in State then。这样,我们将为编译器提供获取数据的确切路径。