View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0030364||Lazarus||LCL||public||2016-07-11 11:21||2016-07-15 00:36|
|Reporter||malcome||Assigned To||Jesus Reyes|
|Product Version||Product Build|
|Target Version||1.8||Fixed in Version||1.7 (SVN)|
|Summary||0030364: We need public "MoveExtend()" in the Grid|
|Description||We need public "MoveExtend()" in the Grid.|
See attached project.
|Tags||No tags attached.|
|Fixed in Revision||52668|
MoveExtend.zip (2,012 bytes)
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.
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.OnSelectCell := @StringGrid1SelectCell;
// If you uncomment next line, you can move!
// TMyGrid(StringGrid1).MoveExtend(false, 2, 2);
||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.|
Ofcourse I know some workaround. Thanks.
A grid.ColRow property is good idea. I am up to you.
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:
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-11 11:21||malcome||New Issue|
|2016-07-11 11:21||malcome||File Added: MoveExtend.zip|
|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|