views:

145

answers:

1
void __fastcall TUsers::DBGColExit(TObject *Sender)
{
    Ado->ExecSQL();
    AQ4->Close();AQ4->Open();
}

after changing content of Table for AQ4 (Ado Query) and reload AQ4 DBG (DBGrid) reloads content too.

but I'm still on not Exit from my Col (Column) (and row) and then when I press on Selected+1 after reload row it selects second row of Grid, if I press Selected+2 it selects third row.

My selected item is first but not first in the same time.

example : DBGrid contains 1 2 3 4 5 I select 4 and reload stuff Then I click on 5 Selects 2 And I just can't click on 1 2 3 4 After reload.

how to fix this bug...

thank you.

+3  A: 

I seriously think "OnColExit" is not the place for what you're doing.

That aside, the behaviour you're describing does not seem to be a bug. By re-opening the dataset you're landing on the first record (navigate with the keyboard instead of the mouse and you'll see what I mean), while the grid thinks it's the column what have been changed.

You should at least try to stay on the same row, by utilizing a bookmark for instance. Delphi equivalent code would be sth. like this;

var
  Bookmark: TBookmark;
begin
  Bookmark := AQ4.GetBookmark;
  try

    [...] // close, open the query

    if AQ4.BookmarkValid(Bookmark) then
      AQ4.GotoBookmark(Bookmark);
  finally
    AQ4.FreeBookmark(Bookmark);
  end;
Sertac Akyuz