Вопрос

I have three DBGrids and three Tables, and two of them are linked with Master Fields and work as expected. When the user clicks on grid-1, it shows three items in grid-2.

When the user clicks on grid-2, I want to use Locate to select the Row in grid-3

Problem is that the grid-2 OnCellClick event is fired before the data has changed to the appropriate Row. e.g.

Grid-2
Flowers  <-- this has focus and Dirt has focus in grid-3
Weeds    
Trees    <-- then I click here

Grid-3
Dirt
Water
Gum     <-- and using Locate in the grid-2 OnCellClick I
            want it to show Gum but grid two is still 
            internally on Flowers and stays on Dirt

It seems that the grid does not change to the Row until after the OnCellClick event.

I need an AfterCellClick event.

Can someone please shed some light on how to go about that?

Thanks

Это было полезно?

Решение

You shouldn't be using OnCellClick. Use the TDataSet.OnAfterScroll instead. It's called automatically when the record (row) pointer is moved, after the movement is done. This means that when the grid attached to the second table is clicked and the record pointer is moved from Flowers to Trees, the second table's OnAfterScroll event will be fired after the row changes, and in that event handler you can do the appropriate Locate in the third table.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top