Depending on what the Sender is it might work if it can be cast to a TDBGrid. Can you actually run an application with that cast? What is the Sender?
I put a DBGrid and a DBMemo on a form and in the OnShow assigned the DataSource property of each to a DataSource I had also placed on the form. Everything worked as expected. Then I changed the assignment to the DBMemo to the following: TDBGrid(DBMemo1).DataSource := DataSource1; Both a syntax check and a build did not throw any errors but if I attempted to run the application it would error out with an access violation as soon as it got to the above assignment. I think that FPC is just catching it at compile time while Delphi is not. Bob On Fri, Jan 17, 2014 at 8:44 PM, Hans-Peter Diettrich <[email protected]>wrote: > Alejandro Gonzalo schrieb: > > In Delphi this will work even if the Sender is not a TdbGrid, as long as >> it has a DataSource property: >> > > It only *happens* to work for you in Delphi. > > TdbGrid(Sender).datasource:=myDataSource; >> > > This hack requires that Sender has a DataSource property in *exactly* the > same place where it sits in TdbGrid. That's very unlikely for any other > class. > > DoDi > > > -- > _______________________________________________ > Lazarus mailing list > [email protected] > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
