How to avoid autoadvance in TStringgrid lazarus / 31-LCL ---------------------------------------------------------------------- MoellerCLaus · 2013-10-20 07:18 If the validation of a cell entry proves wrong (StringGrid1ValidateEntry(sender: TObject; aCol, aRow: Integer; const OldValue: string; var NewValue: String); ) how to hinder advance to next cell? I could set NewValue := OldValue; and nothing bad happens. But for the user interface staying in the cell would be more natural; giving the user a change to correct the mistake. Searching this forum gives the advice about raising an exception; which by others is not recommended Any hint is highly welcomed? ---------------------------------------------------------------------- typo · 2013-10-20 07:43 Quote from: MoellerCLaus on October 20, 2013, 09:18:21 am how to hinder advance to next cell? AFAIK through AutoAdvance property. ---------------------------------------------------------------------- MoellerCLaus · 2013-10-20 07:49 I am afraid I tried this too Code: [Select]    Begin // Does account exist?       Val(NewValue,I,Code);       If Code <> 0 Then         Begin           MessageDlg('Account is not a number!',mtInformation,[mbOk],0);           StringGrid1.AutoAdvance:=aaNOne;           Abort; This code does not give the wanted effect. ---------------------------------------------------------------------- Avishai · 2013-10-20 07:55 I think in case of an error, you would have to set the TStringGrid.Cell[OldCol,OldRow] ---------------------------------------------------------------------- MoellerCLaus · 2013-10-23 17:06 Not quite, but I found a solution - happy to hear about other ways of handling this. In the Grid.ValidateEntry Code: [Select]  If      aCol = KasBL Then     Begin // Check if number       Val(NewValue,I,Code);       if Code <> 0 Then Raise Exception.CreateFmt('Number not correct : ''%s''', [newvalue]);     end and then create an application exception handler Code: [Select]  Application.OnException := @clmExceptionHandler; Where the handler looks like this Code: [Select]procedure TMainForm.clmExceptionHandler(Sender: TObject; E: Exception); Begin   MessageDlg(E.Message,mtInformation,[mbOk],0); end;