Move focus to selected cell

Questions and answers on how to use XLSSpreadSheet.
Post Reply
hung10ngoc
Posts: 7
Joined: Tue Feb 18, 2020 7:44 am

Move focus to selected cell

Post by hung10ngoc »

Please kindly advise how to move focus to the selected cell.

E.g. when set the 'A50' in the cell name and Enter, the display will show the A50 cell.

Thank you in advance for your help!
hung10ngoc
Posts: 7
Joined: Tue Feb 18, 2020 7:44 am

Re: Move focus to selected cell

Post by hung10ngoc »

Solution is:

XSS.SetCursorPos(SheetIndex, 0, 49);
hung10ngoc
Posts: 7
Joined: Tue Feb 18, 2020 7:44 am

Re: Move focus to selected cell

Post by hung10ngoc »

App will show properly if moving focus forward, means from cell with low address to higher one, for example A1 -> BC10. However, when going backward the display is not expected: Cursor moves to correct address but screen remains the same.

I am thinking of going back to A1 cell, refresh the sheet and move focus to the desired one in the case we have to move backward.

Any idea is really appreciated and thankful.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Move focus to selected cell

Post by larsa »

Hello

Use:

Code: Select all

  FXSS.XLS[0].SelectedAreas.CursorCell(5,5);
Lars Arvidsson, Axolot Data
hung10ngoc
Posts: 7
Joined: Tue Feb 18, 2020 7:44 am

Re: Move focus to selected cell

Post by hung10ngoc »

Hi Lars,

Thank you for your reply but unfortunately, it still does not work.

You can try yourself with the 'XLSSpreadSheetAdvanced.dproj' sample.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Move focus to selected cell

Post by larsa »

Hello

You must also call

Code: Select all

FXSS.Invalidate;
in order to make changes visible.
Lars Arvidsson, Axolot Data
hung10ngoc
Posts: 7
Joined: Tue Feb 18, 2020 7:44 am

Re: Move focus to selected cell

Post by hung10ngoc »

Dear Lars,

I have tried your suggestion but the result still keeps unexpected for backward focus changing.

Call FXSS.InvalidateAndReloadSheet, tests with/without data have the same results.

Please kindly advise.
hung10ngoc
Posts: 7
Joined: Tue Feb 18, 2020 7:44 am

Re: Move focus to selected cell

Post by hung10ngoc »

After trying many attempts, the solution is so simple:

FXSS.Read;
hugvis
Posts: 7
Joined: Mon Nov 22, 2021 6:23 pm

Re: Move focus to selected cell

Post by hugvis »

Hi
Anything descriped here does not works here in Delphi 10.3.3
How is possible to move visually the focus and corresponding frame to a given cell and move worksheet in sight if it outsite visible area ?
Rg.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Move focus to selected cell

Post by larsa »

Hello

This question is about TXLSSpreadSheet and not TXLSGrid, which is a toy compared to TXLSSpreadSheet.
Lars Arvidsson, Axolot Data
Post Reply