Subject Re: [IBO] lookupCombo in Grid, strange behaviour
Author scronkey
Hi Helen,
thanks for your reply.

> So, are you calling Refresh on the grid, or the dataset?

I'm aware I should be calling refresh on the dataset, I only
commented on refreshing the grid, because I noticed it had the same
outcome (The lookupCombo was refreshed correctly, but the entire
IB_Grid loses focus)
I also have noted that if I hit F5 (instead of a coded refresh), the
combo is correctly updated but the grid does NOT lose focus. (This
is the desired outcome)

I just cannot seem to find out why the grid loses focus when I do a
coded refresh.

>
> As I recall, the action that you were doing was to change (in
code) the
> lookup key that was selected from the embedded lookupcombo. In
doing that,
> you invalidate the parent dataset row without the "knowledge" of
the
> lookupcombo - so you need to call refresh on the dataset to get
the correct
> KeyDescLinks in the description column that is being sub-selected
by the
> parent query.

That's exactly what I'm doing

>
> By calling Refresh on the dataset, not only should the form's
control focus
> remain undisturbed, but you can specify that the current row and
column
> also remain the same, by using RefreshAction raKeepDataPos.

I have tried this (raKeepDataPos), but the outcome is the same. The
grid loses focus when I have a hard-coded refresh on the dataset...
I cannot see anywhere any code that would make the grid lose focus
though.


I have found a work around, but I'm not sure if it is good practice.
Instead of having the DetailDataSet refresh straight after I change
the lookup key, I do the refresh in the AfterPost event.
This has the desired outcome (lookupCombo displays correct data &
grid still has focus)
But it seems a little over done to do a refresh in the AfterPost
event.

Has this foreseeable problems? If it does, maybe I could flag when I
have updated the lookup key, and only do a refresh in the AfterPost
when this flag is true.

Rgds,
-Ryan