Recent

Author Topic: Moving cells in grid - explanation unclear  (Read 4175 times)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Moving cells in grid - explanation unclear
« on: December 16, 2012, 02:05:35 pm »
Hi,

I'm trying to convert Delphi code that uses MoveColRow to go to a cell in a grid.

Looking here:
http://wiki.lazarus.freepascal.org/Grids_Reference_Page#Grid.27s_cell_selection
and in the help I see a description of what happens when changing/trying to change the currently selected cell.

However, it does not show how to do it. I assume one should just use SelectCell, so that text can be changed from
Quote
The location of a grid's current (focused) cell (or row) can be changed using keyboard, mouse or through code. In order to change cell focus successfully to another position, we must test the target position to see if it is allowed to receive cell focus. When using keyboard, the property AutoAdvance performs part of the process by finding what should be the next focused cell. When using mouse clicks or moving by code, focus will not move from the current cell unless the target cell is permitted to receive focus.
to:
Quote
The location of a grid's current (focused) cell (or row) can be changed using keyboard, mouse or through code. In order to change cell focus successfully to another position, we must test the target position to see if it is allowed to receive cell focus.

When using the keyboard, the property AutoAdvance performs part of the process by finding what should be the next focused cell.

When using mouse clicks or moving by code (e.g. using SelectCell), focus will not move from the current cell unless the target cell is permitted to receive focus.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Moving cells in grid - explanation unclear
« Reply #1 on: December 16, 2012, 02:46:37 pm »
Quote
I'm trying to convert Delphi code that uses MoveColRow to go to a cell in a grid.
MoveColRow is not a method to go to a cell in Grid. It is a method to move Column/Row and all its content from FromIndex to ToIndex. My experience is that it has nothing to do with AutoAdvance (not sure about SelectCell, but my quick test shows that OnSelectCell event is not raised during MoveColRow, even if focused position has changed).

EDIT: I added a simple test. You don't have to press button, just run it.
« Last Edit: December 16, 2012, 02:56:10 pm by Blaazen »
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Bart

  • Hero Member
  • *****
  • Posts: 5757
    • Bart en Mariska's Webstek
Re: Moving cells in grid - explanation unclear
« Reply #2 on: December 16, 2012, 03:22:50 pm »
I'm trying to convert Delphi code that uses MoveColRow to go to a cell in a grid.

Maybe I'm to simple but wouldn't just this do that:

Code: [Select]
  StringGrid1.Row := MyRow;
  StringGrid1.Col := MyCol;

Bart

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Moving cells in grid - explanation unclear
« Reply #3 on: December 16, 2012, 04:16:29 pm »
Thanks guys.
@Bart: well yes, it might do that. I'm perhaps being too complicated again ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018