Board index » delphi » Detecting what table is in use from within grid?

Detecting what table is in use from within grid?

I just started playing with Infopower from Woll2Woll and I am encountering a problem
brought on by the use of components embedded within grids.  I need a way to detect what
table the current grid is connected to while within an embedded component so I can
address it to move the cursor, insert, delete, etc.

Without the embedded components I can just use (ActiveControl as TDBGrid), but from
within the component it is the ActiveControl, so that no longer works.  I tried setting
a flag in the grid's onEnter and onExit method, but once you enter the embedded
component you exit the grid so that didn't work.  I could test for every embedded
component within every grid on the form to see what table I am in, but that would be a
pain.

Ideally I would also like to keep track of the last grid that had focus so I could leave
the grid to use an incremental search or other component and still move the cursor,
delete, etc., within the table I just left without having to move back to it first.

Any suggestions woulf be GREATLY appreciated!
--
bgsis...@datasync.com
bgsis...@ocean.st.usm.edu

 

Re:Detecting what table is in use from within grid?


Quote
Byron Sisson <bgsis...@datasync.com> wrote:
> I just started playing with Infopower from Woll2Woll and I am encountering a problem
> brought on by the use of components embedded within grids.  I need a way to detect what
> table the current grid is connected to while within an embedded component so I can
> address it to move the cursor, insert, delete, etc.

> Without the embedded components I can just use (ActiveControl as TDBGrid), but from
> within the component it is the ActiveControl, so that no longer works.  I tried setting
> a flag in the grid's onEnter and onExit method, but once you enter the embedded
> component you exit the grid so that didn't work.  I could test for every embedded
> component within every grid on the form to see what table I am in, but that would be a
> pain.

> Ideally I would also like to keep track of the last grid that had focus so I could leave
> the grid to use an incremental search or other component and still move the cursor,
> delete, etc., within the table I just left without having to move back to it first.

Couldn't that be done by defining a variable with scope needed, say
LastGridDatasource, and set that var to
        (Sender as TwwDBGrid).Datasource
in the OnEnter (or OnExit) event of each grid?

Jasper

PS: please take into consideration
- when replying, I just think I know;
- when asking, be sure that I don't.

Other Threads