Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

AdvEdit.OnChange

 Post Reply Post Reply
Author
Hruška Stanislav View Drop Down
Member
Member
Avatar

Joined: 22 Mar 2016
Posts: 45
Post Options Post Options   Quote Hruška Stanislav Quote  Post ReplyReply Direct Link To This Post Topic: AdvEdit.OnChange
    Posted: 03 Dec 2019 at 5:50pm
I need to edit the values in other AdvEdit (new status and difference) based on the value change in MyAdvEdit.
MyAdvEdit - accuracy is 2
The problem is that the OnChange event is called twice. First time when changing data, second time when formatting. This is undesirable. I can't tell.
Auxiliary variables didn't help me. For formatted OnChange, they contain the original values and not updated. I did not find another suitable event.
How can this be solved?
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8596
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 03 Dec 2019 at 9:44pm
I cannot see a problem.
Please provide FULL and EXACT information, property settings, event handler code, setup code, steps ...
Back to Top
Hruška Stanislav View Drop Down
Member
Member
Avatar

Joined: 22 Mar 2016
Posts: 45
Post Options Post Options   Quote Hruška Stanislav Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 2019 at 10:46pm
I have MyEdit1..n and SumEdit. I enter values into MyEdit. I am updating the SumEdit value as you type.
An example of SumEdit.FloatValue is 100. I write 5 to MyEdtix. In MyEdtix.OnChange I have SumEdit.FloatValue: = MyEdit.FloatValue. The resulting value in SumEdit = 110.00 and not 105.00
Sorry, I was waiting for an e-mail :)
Back to Top
Hruška Stanislav View Drop Down
Member
Member
Avatar

Joined: 22 Mar 2016
Posts: 45
Post Options Post Options   Quote Hruška Stanislav Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 2019 at 10:47pm
Edit:SumEdit.FloatValue: = SumEdit.FloatValue + MyEdit.FloatValue
Back to Top
Hruška Stanislav View Drop Down
Member
Member
Avatar

Joined: 22 Mar 2016
Posts: 45
Post Options Post Options   Quote Hruška Stanislav Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 2019 at 7:50am
It's all me. The most important:
Precision = 2
EditType = etMoney
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8596
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 2019 at 2:54pm
Thanks for reporting the issue was resolved.
Back to Top
Hruška Stanislav View Drop Down
Member
Member
Avatar

Joined: 22 Mar 2016
Posts: 45
Post Options Post Options   Quote Hruška Stanislav Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 2019 at 10:05pm
We don't understand a bit. The Precission property must be greater than 0. Otherwise, an "error" will not occur. The "Formating" event, and consequently the OnChange event, does not occur.
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8596
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 08 Dec 2019 at 9:33am
I retested this with 3 default TAdvEdit controls on the form and the code:

procedure TForm2.AdvEdit1Change(Sender: TObject);
begin
  advedit3.FloatValue := advedit1.FloatValue + advedit2.FloatValue;
end;

procedure TForm2.AdvEdit2Change(Sender: TObject);
begin
  advedit3.FloatValue := advedit1.FloatValue + advedit2.FloatValue;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  advedit1.EditType := etMoney;
  advedit1.Precision := 2;
  advedit2.EditType := etMoney;
  advedit2.Precision := 2;
  advedit3.EditType := etMoney;
  advedit3.Precision := 2;
end;

I cannot see any moment that the calculation is wrong here.
Back to Top
Hruška Stanislav View Drop Down
Member
Member
Avatar

Joined: 22 Mar 2016
Posts: 45
Post Options Post Options   Quote Hruška Stanislav Quote  Post ReplyReply Direct Link To This Post Posted: 08 Dec 2019 at 10:51am
I sent a primitive form to try it on.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down