Board index » delphi » Get Value from DBGrid

Get Value from DBGrid

 I'm migrating from VB so be gentle with me <g>.
How do I retrieve the value from whatever field I click in a DBGrid?
Example: DBGrid is based on customer table. I click the
CUST_ID field for a given record. On the on-click event for the
DBGrid I want to pass the CUST_ID to a global function. How do I pass the
value?

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

 

Re:Get Value from DBGrid


If your grid is populated by a Query or Table called Source1, and you
wanted the name of the field as a string variable you could do
something like:

Global_Fn(Source1.FieldByName('CUST_ID').AsString);

If the Tfield is defined in the code, you could also do something like

Global_Fn(Source1Cust_ID.AsString);

Which would be faster but requires that the TField is defined at
design time.

Check out the function FieldByName() on the datasets as a starting
point.  That should work.

Good luck,
Ed

Quote
On Tue, 18 Mar 1997 07:32:15 -0600, fam...@qcontinuum.com wrote:
> I'm migrating from VB so be gentle with me <g>.
>How do I retrieve the value from whatever field I click in a DBGrid?
>Example: DBGrid is based on customer table. I click the
>CUST_ID field for a given record. On the on-click event for the
>DBGrid I want to pass the CUST_ID to a global function. How do I pass the
>value?

>-------------------==== Posted via Deja News ====-----------------------
>      http://www.dejanews.com/     Search, Read, Post to Usenet

Other Threads