Board index » delphi » DBGrid access

DBGrid access

Hi, sorry for the relatively easy question, but I
simply cannot figure this one out.

How do I access random entries(records) in a DbGrid? I seem to
only be able to return the field that is currently
selected by the user.

var
     f : tfield;
begin
     f := dbgrid1.fields[X];  // where X is some number

// If I do this, then f.asstring is the Xth column of the
   user selected entry

How do I access a row of a dbgrid not selected by the user?

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

 

Re:DBGrid access


temp...@hotmail.com wrote in article <878229601.17...@dejanews.com>...

Quote
> Hi, sorry for the relatively easy question, but I
> simply cannot figure this one out.

> How do I access random entries(records) in a DbGrid? I seem to
> only be able to return the field that is currently
> selected by the user.

> var
>      f : tfield;
> begin
>      f := dbgrid1.fields[X];  // where X is some number

> // If I do this, then f.asstring is the Xth column of the
>    user selected entry

> How do I access a row of a dbgrid not selected by the user?

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

I think that a DBGrid is for viewing and user editing of data. For
programme access of records other than the current record (that selected by
the user) I suggest using:

Lookup -  if you want to read data from another record

Locate - if you want to modify another record.

If using Locate, you can use another view of the data (e.g. another
TTable), or bookmark the current record for later return in the existing
table.

Regards, Tom.

Re:DBGrid access


Quote
temp...@hotmail.com wrote:

> Hi, sorry for the relatively easy question, but I
> simply cannot figure this one out.

> How do I access random entries(records) in a DbGrid? I seem to
> only be able to return the field that is currently
> selected by the user.

> var
>      f : tfield;
> begin
>      f := dbgrid1.fields[X];  // where X is some number

> // If I do this, then f.asstring is the Xth column of the
>    user selected entry

> How do I access a row of a dbgrid not selected by the user?

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

you should change the pointer to the different record of the table

either use table.first;
           table.moveby(x)

where x is the record nr you wish to see

or use other methods like locate etc.

Cheers
Conrad Smith

Re:DBGrid access


Quote
temp...@hotmail.com wrote:
> Hi, sorry for the relatively easy question, but I
> simply cannot figure this one out.

> How do I access random entries(records) in a DbGrid? I seem to
> only be able to return the field that is currently
> selected by the user.

> How do I access a row of a dbgrid not selected by the user?

navigate through the dataset using ds.next, .last, etc
--
<x-rich>

Andrew Ward       mailto:andr...@techie.com

  http://www.newcollege.unsw.edu.au/andreww

"In those days spirits were brave, the stakes were high,

men were <italic>real</italic> men, women were <italic>real</italic>
women,

and small {*word*141} creatures from Alpha Centauri were

<italic>real</italic> small {*word*141} creatures from Alpha Centauri."

-The Hitchhiker's Guide to the Galaxy</x-rich>

Other Threads