When used DBGridEh in a script form, than called the DrawColumnEhCell even,I got an error message.
Exception class EInvalidCast with message 'Invalid class typecast'.
// The Script is very easy:
procedure DBGridEh1DrawColumnCell(Sender: TObject; Rect: TRect; DataCol: Integer;
Column: TColumnEh; State: TGridDrawState);
begin
if ((DBGridEh1.DataSource.Dataset.FieldByName('ItemNo').AsInteger mod 2) =0) then
begin
DBGridEh1.Canvas.Font.Color := clYellow;
DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State); // error here
end;
end;
//-----------------------------------------------------------------------------------------------------
// register code:
procedure TatDBGridEhDispatcher.__TDrawColumnEhCellEvent( Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
var
StateTempSet: TGridDrawState;
StateTemp: variant;
ColumnTemp:Variant;
RectTemp:TRectWrapper;
begin
if DoOnExecuteEvent then
begin
if AssignedMethod(BeforeCall) then
TDrawColumnEhCellEvent(BeforeCall)(Sender,Rect,DataCol,Column,State);
StateTempSet := State;
StateTemp := IntFromSet(StateTempSet, SizeOf(StateTempSet));
RectTemp:= TRectWrapper.Create(Rect);
ColumnTemp:= ObjectToVar(Column) ;
if Assigned(Scripter) and (RoutineName > '') then
Scripter.ExecuteSubroutine(RoutineName, [Sender,RectTemp,DataCol,ColumnTemp,StateTemp]);
RectTemp.Free;
if AssignedMethod(AfterCall) then
TDrawColumnEhCellEvent(AfterCall)(Sender,Rect,DataCol,Column,State);
end;
end;
Where did I make a mistake?
Best regards.