Reputation: 313
I have a situation where I have to allow the user to update either of 2 fields of a dbgrid(connected to a CDS) persisting the last entered one. So (after user enters data) I need to get the current focused control, so that i will remove the previous field data if it has any. I also have other fields apart from these two.
It was insisted not to use any grid related events, i have to use only CDS event to achieve this.
Thanks in advance, Vijay.
Upvotes: 1
Views: 487
Reputation: 17203
Use the field's OnChange event, and just clear the other field value if any:
Something like this:
TForm1.cdsField1Change(Sender: TField);
begin
if not Sender.IsNull then
cdsField2.Clear;
end;
TForm1.cdsField2Change(Sender: TField);
begin
if not Sender.IsNull then
cdsField1.Clear;
end;
Upvotes: 4