DBgrid celules lazarus / 31-LCL ---------------------------------------------------------------------- Fabius · 2021-06-10 14:38 Hello everyone I have the following problem in a DBgrid I have two columns I want only one of the two columns to be greater than zero, at user input I did this, but it doesn't work for the last DEBIT field Do you have an idea ? 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     if DBGrid1.SelectedField.FieldName = 'CREDIT' then    begin    StatusBar1.SimpleText := 'Champ Credit';      if DBGrid1.Columns[2].Field.Value > 0 Then      begin      DBGrid1.Columns[3].Field.Value := 0; ///////////debit   OK this OK the field ZERO       ///DBGrid1.DataSource.DataSet.Last();      end;      calcullignes;     end;       if DBGrid1.SelectedField.FieldName = 'DEBIT' then    begin       if DBGrid1.Columns[3].Field.Value > 0 Then  //////////champ debit      begin            DBGrid1.Columns[2].Field.Value := 0;  ////////credit  NOT to ZERO ??     StatusBar1.SimpleText := 'Credit A zero ';   ///ok       end;    calcullignes;     end; ---------------------------------------------------------------------- bpranoto · 2021-06-10 17:26 Do the job on the OnChange of the fields. 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 // Apply this to the OnChange event of the field DEBETprocedure TForm1.Dataset1debetChange(Sender: TField);begin  if Sender.AsFloat > 0 then begin    DataSet.FieldByName('CREDIT').AsFloat := 0;  end;end; // Apply this to the OnChange event of the field CREDITprocedure TForm1.Dataset1kreditChange(Sender: TField);begin  if Sender.AsFloat > 0 then begin    DataSet.FieldByName('DEBET').AsFloat := 0;  end;end; ---------------------------------------------------------------------- Fabius · 2021-06-11 04:19 Hello No onchange event on the dbgrid fields? If there was it would be great Or have I not seen ?? Of course I could link the table to dbedit and modify by them but I am trying to modify by the dbgrid it is an accounting software and i would like to enter the values ​​in the dbgrid ---------------------------------------------------------------------- bpranoto · 2021-06-11 07:15 Quote from: Fabius on June 11, 2021, 06:19:19 amHello No onchange event on the dbgrid fields? The event is not on the TDBGrid (..and TDBGrid of course doesn't have fields). It is on the Dataset fields. ---------------------------------------------------------------------- bpranoto · 2021-06-11 07:39 Here is a simple demo. Is this what you want? ---------------------------------------------------------------------- Fabius · 2021-06-11 12:42 Thank You , I test