View Issue Details

IDProjectCategoryView StatusLast Update
0030364LazarusLCLpublic2016-07-15 00:36
ReportermalcomeAssigned ToJesus Reyes 
Status closedResolutionfixed 
Product VersionProduct Build 
Target Version1.8Fixed in Version1.7 (SVN) 
Summary0030364: We need public "MoveExtend()" in the Grid
DescriptionWe need public "MoveExtend()" in the Grid.
See attached project.
TagsNo tags attached.
Fixed in Revision52668
Attached Files



2016-07-11 11:21

reporter (2,012 bytes)

Jesus Reyes

2016-07-11 23:32

developer   ~0093660

Last edited: 2016-07-11 23:54

View 2 revisions

The exact purpose of CanSelect in SelectCell is to indicate which cells are selectable. Because you are "saying" the grid that only diagonal cells where col=row are selectable, no other cell in the grid would be. If I'm misinterpreting the issue please clarify.


2016-07-11 23:42

developer   ~0093661

I would not publish this method. It is a very central method and it is not clear what happens if it is called at the wrong time.

In your demo, you restrict selection of cells only to diagonal cells. When you first set the Col of the selected cell and then its row the selecte cell moves off-diagonal, and in total the selected cell does not move at all.

But instead of using MoveExtend I would temporarily disable the OnSelect event handler, set the Col and Row of the new position, and then enable the OnSelect handler again. This works (tested):

procedure TForm1.SpeedButton1Click(Sender: TObject);
  StringGrid1.OnSelectCell := nil;
  StringGrid1.Col:=2; StringGrid1.Row:=2;
  StringGrid1.OnSelectCell := @StringGrid1SelectCell;
  // If you uncomment next line, you can move!
// TMyGrid(StringGrid1).MoveExtend(false, 2, 2);

Jesus Reyes

2016-07-12 00:57

developer   ~0093662

Another way would be adding a grid.ColRow property, public only on TCustomDrawGrid, which would return or set in one run both col and row properties.


2016-07-12 01:39

reporter   ~0093663

Ofcourse I know some workaround. Thanks.

A grid.ColRow property is good idea. I am up to you.

Jesus Reyes

2016-07-12 02:46

developer   ~0093664



2016-07-12 10:50

developer   ~0093669

I would have preferred a method instead of a property. The ColRow property requires two steps to move the col/row: populate the TPoint, and assign it to the property:
  P := Point(2, 2);
  Grid.ColRow := R;

A method would have done the same in a single step:

  Grid.SetQuickColRow(2, 2);

Jesus Reyes

2016-07-12 11:17

developer   ~0093671

Last edited: 2016-07-12 11:17

View 2 revisions

It's an extension of two properties, it's just natural it is a also a property. You can define it where it belongs: TCustomGrid and hide it where it's needed (TDbGrid for example). I prefer to not use SetXXXX methods on public visibility (not a rule, just a preference). (1 step 2 step) If you find a situation where really matters, we can change it.


2016-07-15 00:36

reporter   ~0093716


Issue History

Date Modified Username Field Change
2016-07-11 11:21 malcome New Issue
2016-07-11 11:21 malcome File Added:
2016-07-11 23:29 Jesus Reyes Assigned To => Jesus Reyes
2016-07-11 23:29 Jesus Reyes Status new => assigned
2016-07-11 23:32 Jesus Reyes LazTarget => 1.8
2016-07-11 23:32 Jesus Reyes Note Added: 0093660
2016-07-11 23:32 Jesus Reyes Status assigned => resolved
2016-07-11 23:32 Jesus Reyes Fixed in Version => 1.7 (SVN)
2016-07-11 23:32 Jesus Reyes Resolution open => no change required
2016-07-11 23:32 Jesus Reyes Target Version => 1.8
2016-07-11 23:42 wp Note Added: 0093661
2016-07-11 23:54 Jesus Reyes Note Edited: 0093660 View Revisions
2016-07-12 00:57 Jesus Reyes Note Added: 0093662
2016-07-12 01:39 malcome Note Added: 0093663
2016-07-12 02:46 Jesus Reyes Fixed in Revision => 52668
2016-07-12 02:46 Jesus Reyes Note Added: 0093664
2016-07-12 02:46 Jesus Reyes Resolution no change required => fixed
2016-07-12 10:50 wp Note Added: 0093669
2016-07-12 11:17 Jesus Reyes Note Added: 0093671
2016-07-12 11:17 Jesus Reyes Note Edited: 0093671 View Revisions
2016-07-15 00:36 malcome Note Added: 0093716
2016-07-15 00:36 malcome Status resolved => closed