Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting in a DBGrid

Status
Not open for further replies.

bobstery

Programmer
Aug 18, 2003
4
GB
How do I select all the entries I have within a DBGrid i.e.
I want the user to follow out a query and then automatically select all the entries returned from the query.

I know how to let the user select a row by themselves, but I don't know how to do it programmatically.
 
Do you have to use the GRID ?

What I mean is , if it's a DBGRid then you will know ( programmatically ) what the data source is for that grid.

By opening the actual Table or Query component that makes up the grids data then you can step through the grid and process whatever you want... either a single record or all of them ?

Suppose DBGrid1 has datasource DataSource1
Suppose DataSource1 has Data object Table1

By using the following :

int i = 0;

for ( i = 0 ; i < Table1->RecordCount; i++ )
{
FieldValue = Table1->FieldByName(&quot;FieldName&quot;)->AsString;
...
}

will enable you to step through the table and process the data however you like. ( Same code if it's a Query object as opposed to TTable )

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top