<div dir="ltr">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?<div><br></div><div>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:<div>
<br></div><div>TDBGrid(DBMemo1).DataSource := DataSource1;</div><div><br></div><div>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.</div>
</div><div><br></div><div>I think that FPC is just catching it at compile time while Delphi is not.</div><div><br></div><div>Bob</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 17, 2014 at 8:44 PM, Hans-Peter Diettrich <span dir="ltr"><<a href="mailto:DrDiettrich1@aol.com" target="_blank">DrDiettrich1@aol.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Alejandro Gonzalo schrieb:<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In Delphi this will work even if the Sender is not a TdbGrid, as long as it has a DataSource property:<br>
</blockquote>
<br></div>
It only *happens* to work for you in Delphi.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  TdbGrid(Sender).datasource:=<u></u>myDataSource;<br>
</blockquote>
<br>
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.<br>
<br>
DoDi<br>
<br>
<br>
--<br>
______________________________<u></u>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus</a><br>
</blockquote></div><br></div>