Recent

Author Topic: [solved] Extend TStringgrid 2  (Read 1047 times)

Danccce

  • New member
  • *
  • Posts: 7
[solved] Extend TStringgrid 2
« on: May 25, 2018, 02:12:43 pm »
HI again,

I've another problem extending a TStringGrid

Code: Pascal  [Select][+][-]
  1.   TMLExtendedStringGrid = class(TStringGrid)
  2.   private
  3.   protected
  4.     procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
  5.     procedure SelectCell(aCol, aRow: LongInt); override;
  6.   public
  7.     constructor Create(AOwner: TComponent); override;
  8.   end;
  9.  

When compiling I've got the error message:
Quote
Error: There is no method in an ancestor class to be overridden: "SelectCell(LongInt;LongInt);"

How is the right call?

Best regrads...
« Last Edit: May 25, 2018, 02:32:46 pm by Danccce »

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Extend TStringgrid 2
« Reply #1 on: May 25, 2018, 02:23:02 pm »
Your class inherits from TStringGrid, SelectCell is inherited - this means that you must use the EXACT parameters like in the ancestor. So: Hold CTRL down and click on SelectCell. Lazarus will open the source file with the declaration of TStringGrid.SelectCell (or implementation, depending on version). Here you can see the correct call parameters. In this case you'll find that ARow and ACol are declared as "integer", not as "longint".

Navigating through source code by using CTRL-click method is the best method to learn about how the source works.
« Last Edit: May 25, 2018, 02:24:47 pm by wp »

Danccce

  • New member
  • *
  • Posts: 7
Re: Extend TStringgrid 2
« Reply #2 on: May 25, 2018, 02:32:27 pm »
Oh no,

I just overread that SelectCell is NOT a procedure but a function  :'(

Thank you ...

 

TinyPortal © 2005-2018