Re:Retrieving all row values from selected row in DBGrid
Quote
Steve Champeau wrote:
> I have a table that I want to display in a DBGrid that contains data
> summarized at several different levels. The rows that are at the
> lowest
> level of summarization will have several editable columns. When the
> user
> changes one of these editable values, related values will be
> recomputed
> and display refreshed for all the higher level rows of summarization.
> In
> other words, any change at the lowest level will trickle upward to all
> higher levels. In addition to the columns that are actually displayed
> in
> the DBGrid, the table will include numerous other columns from which
> SQL
> UPDATE strings can be built to make these changes at the higher
> levels.
> My problem is that I do not know how to return the column values for a
> row that the user selects. If a user changes a value in a cell, how
> does
> one go about retrieving the values of other columns of the selected
> row,
> either those displayed in the DBGrid or those in the table but not
> displayed?
> Thanks for any help,
> Steve C.
Hi Steve .
There are two ways on doing that all of them in the ttable component.
a)use the fieldbyname method returning a Tfield type and use the
Tfield.asinteger or what other method you wish e.g
You have a table named A and in there you a record with to fields typed
as number(N) with the names f1,f2 you call it like this
A.fieldbyname('f1').asstring
this returns the fields values in string format see Tfield for more
info.
B) you can uses the fields property wich returns the same think with the
Fieldbyname but using the position of the field in the file e.g. f1 is
at pos 0 and f2 at pos 1. you use it like this
A.fields[0].asstring; to get a string representation of the f1 field's
contents.
To the mater of choosing the corect row there is no need the dbgrid
moves the database cursor live so geting the ttables values you allways
get the curent cursor's position values;
Regards
Johnny