descendent custom tstringgrid lazarus / 31-LCL ---------------------------------------------------------------------- Deepaak · 2021-07-28 07:03 Hi everyone, I have stuck at a strange problem. Actually i am creating a custom grid which descend from TStringGrid. Everything was going smooth when I got stuck. I want to override OnSelectCell event in my custom grid. So that if the Cell is empty then the cell will not be selected, without any user code in the form. I am bit confused on what function to override to achieve this. Will i have to check for empty row/coumn in keydown, keyup event or have to override OnSelectCell event. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  TABCGrid = class(TStringGrid)  private  protected    procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;    //procedure SelectCell(aCol, aRow: LongInt); override;    function SelectCell(aCol, aRow: LongInt): boolean; override;  public    constructor Create(AOwner: TComponent); override;  end;  When overriding SelectCell entire ide freezes and have to terminate the process of lazarus. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Result:=inherited SelectCell(ACol, ARow);  If (Cells[ACol, ARow].Trim.IsEmpty) Then Begin    Result := False;    if Assigned(OnSelectCell) then OnSelectCell(Self, aCol, aRow, Result);  end else begin      if Assigned(OnSelectCell) then OnSelectCell(Self, aCol, aRow, Result);  end; ---------------------------------------------------------------------- lucamar · 2021-07-28 07:55 A couple little things come inmediately to mind: first, why do you call it TCustomGrid? That will override the TCustomGrid from Grids unit Second, you're declaring SelectCell as a procedure, but it's a function in the base class, which means that you're actually "hiding" (or overloading, I'm not sure which) rather than overriding (OK if is's intentional) and that all your: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Result := whatever;inside it are doing nothing ... indeed they should be causing compilation errors Might be that is what is happening? Sometimes the IDE gets a little lost and doesn't brings to front the message window or fails to select the line with the error in the editor ... though TBH it can't be confused with a frozen IDE ---------------------------------------------------------------------- Deepaak · 2021-07-28 14:25 Firstly Sorry! It was typo as I wrote from mobile  Code is rectified. I just want to implement the same feature that is provided in OnSelectCell(Sender, col,row, canfocus) Whenever the cell is empty then the cell must be skipped just like CanFocus does. I want to override this feature in my custom grid, so that this operation will become transparent. ---------------------------------------------------------------------- lucamar · 2021-07-28 15:26 Ah, OK. In that case, call neither the inherited SelectCell or OnSelectCell if the cell is empty: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Result := not Cells[ACol, ARow].Trim.IsEmpty            and inherited SelectCell(ACol, ARow);In the normal state, with short-circuit evaluation on, that will first check whether: Cells[ACol, ARow].Trim.IsEmpty = True and if so, because the not, it'll result False, in which case the and would result in False and there is no need to evaluate (or execute) the inherited SelectCell(). Also, there is no need to test and call OnSelectCell since the ancestor SelectCell() in TCustomDrawGrid already does it. Note that I have not tested this so it might not work ... though it should if all else is right. HTH! ---------------------------------------------------------------------- Deepaak · 2021-07-28 16:00 I will test the code and update. Update 1: Tested the code, but when the component is inserted in the form, then whole ide freezes and have to terminate .