Forum > LCL

DBgrid celules

(1/2) > >>

Fabius:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    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:
Do the job on the OnChange of the fields.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// 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:
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:

--- Quote from: Fabius on June 11, 2021, 06:19:19 am ---Hello

No onchange event on the dbgrid fields?


--- End quote ---

The event is not on the TDBGrid (..and TDBGrid of course doesn't have fields).

It is on the Dataset fields.

bpranoto:
Here is a simple demo.

Is this what you want?

Navigation

[0] Message Index

[#] Next page

Go to full version