Question

I am using TcxGridDBBandedTableView and have two columns of type TcxGridDBBandedColumn.

vwABC : TcxGridDBBandedTableView
vwABCField1 : TcxGridDBBandedColumn
vwABCField2 : TcxGridDBBandedColumn

When I change anything in vwABCField1, vwABCField2 values should get cleared. For this I am using OnEditValueChanged property of vwABCField1 like this:

procedure TMyForm.vwABCField1PropertiesEditValueChanged(Sender: TObject);
begin
  vwABCField2.EditValue := '';
end;

While debugging, when I come to vwABCField2.EditValue := ''; statement, I never return back and get trapped in infine loop and after some time I get stackoverflow error.

vwABCField2.EditValue := ''; is calling vwABCField1PropertiesEditValueChanged procedure again and again recursively infinite time. I don't know why. I have not declared anything on OnEditValueChanged event of vwABCField2.

Update

If I write anything else in the above function instead of vwABCField2.EditValue := '';, it will be called only once. For example

procedure TMyForm.vwABCField1PropertiesEditValueChanged(Sender:TObject); 
begin   
  ShowMessage("hi"); 
end;

works fine. So I suspect that culprit is vwABCField2.EditValue := ''; statement.

Was it helpful?

Solution

As in the official documentation is stated:

Do not change the edit value in your OnEditValueChanged event handler, as this can result in stack overflow. Use this event to get notification that the edit value has changed.

Because when you change the edit value in this event, of course, your editvalue is changed and therefore calling the OnEditValueChanged event again and again and ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top