TDBAdvGrid - programmatically horizontal scrolll

Hello
I am using TDBAdvGrid with PageMode=True and provide column sorting on the dataSource level. After modifying dataSource Sql query I reopen the query. This causes the grid to scroll top-left. Going top row is not a problem, but I would like to return to the column displayed previously. Especially if there are many columns this is very inconvinient. I cant find how to restore visible columns. I can send WM_HSCROLL to the controll and it causes scrolling, but I dont know how much. Is there any event fired after scrolling so I could store the position? Or any other way to do it programmatically?

Saving / reassigning the value from/to your grid's Col property should solve your problem.

  LLastFocusedCol := WorkGrid.Col;
  WorkDataset.Close;
...
  WorkDataSet.Open;
  WorkGrid.Col := LLastFocusedCol;

Thanks Julio, I will check it and give you feedback

The horizontal scroll position of the grid is programmatically controlled by the grid.LeftCol: integer property.

Julio's tip didnt work. I think I have tried with the LeftCol, will check once again, thank you.

I can see than at the start of the OnCanSort() event the LeftCol property is properly set. However it seems setting it back directly after making Query->Active to true, yet inside this event, has no effect. Perhaps I should post the message and set it outside of the event handler?.

Can you please give more context & details so we can understand the full scope of what you are trying to achieve.
Grid.LeftCol: integer programmatically sets the horizontal scroll position. If you do more things that could affect this, please provide sufficient details.

Sorry, I don't have a CanSort event, but changing Col &/or LeftCol worked under a simple test, with no need for handling messages. Maybe if you paste this part of your code could help.