View Issue Details

IDProjectCategoryView StatusLast Update
0027232LazarusDatabase Componentspublic2015-04-22 14:14
ReporterLuca Olivetti Assigned ToJesus Reyes  
Status closedResolutionfixed 
Product Version1.2.6 
Target Version1.4Fixed in Version1.5 (SVN) 
Summary0027232: TDBGrid doesn't fire OnSelectEditor if scrolling past visible extent
DescriptionWhen scrolling past the visible rows (either using the up/down arrow, a db navigator or the scrollbar of the grid) the OnSelectEditor event doesn't fire even if the record has changed.
If an editor was previously selected, now it would show the value of the previous record and, worse, it could lead to an unintended modification of the new record.
Steps To ReproduceCompile and run the attached project. It should load enough test data to fill more than the visible rows.
Click on any cell and see that in the memo is registered the firing of the OnSelectEditor event.
Click on the first cell of the last visible row and again see that OnSelectEditor fires.
Now use the keyboard down arrow to select the next row. OnSelectEditor isn't fired this time.
Additional InformationTested both under windows and linux.
TagsNo tags attached.
Fixed in Revision47911
Attached Files


Luca Olivetti

2015-01-02 10:01

reporter (3,154 bytes)

Luca Olivetti

2015-01-28 12:14

reporter   ~0080636

SelectEditor is only triggered if the Row changes (in Grids.pas, TCustomGrid.SetRow exits if it's the same row, so it doesn't call MoveExtend which actually calls SelectEditor), *but* since we're scrolling the grid, the row number doesn't change event if the record has changed.

I don't think it's enough to call SelectEditor in TCustomDBGrid.OnDataSetScrolled (in case Distance<>0) because MoveExtend also checks for editability and the AlwaysShowEditor option, i.e., this is what MoveExtend does


  if (FEditor<>nil) and EditorAlwaysShown then begin
    // if editor visibility was changed on BeforeMoveSelection or MoveSelection
    // make sure editor will be updated.
    // TODO: cell coords of last time editor was visible
    // could help here too, if they are not the same as the
    // current cell, editor should be hidden first too.
    if FEditor.Visible then

but neither FEditor nor EditorAlwaysShown are visible to the TDbGrid.
The former could be substituted for its accessor InplaceEditor and EditorAlwaysShown by (dgAlwaysShowEditor in Options) (though it is incomplete).
Or maybe the above could be put in a protected method of the Grid than can be called by the DbGrid.

What do you think?

Luca Olivetti

2015-01-28 16:03

reporter   ~0080642

Actually the above is not necessary, because TCustomDBGrid.OnDataSetScrolled already hides and (if necessary) shows the editor.
Just adding a call to SelectEditor in the

if Distance<>0 then begin

part should be enough (I put it after the Invalidate).

Jesus Reyes

2015-02-20 03:23

developer   ~0081273

Thanks, I modified the patch to avoid that eventually OnSelectEditor would be called twice

Luca Olivetti

2015-02-20 16:46

reporter   ~0081286

Thank you. Will it be merged in the upcoming 1.4?

Jesus Reyes

2015-03-03 01:15

developer   ~0081583

I'm sorry, it's now queued.

Luca Olivetti

2015-04-22 11:05

reporter   ~0083106

Lazarus 1.4 has been released today without this fix

Jesus Reyes

2015-04-22 13:25

developer   ~0083111

what you mean?, I can see the patch in the release, the one before the tagging:

Luca Olivetti

2015-04-22 14:14

reporter   ~0083113

Sorry for the noise, I was misled by the merge to my local version from the subversion repository.

Issue History

Date Modified Username Field Change
2015-01-02 10:01 Luca Olivetti New Issue
2015-01-02 10:01 Luca Olivetti File Added:
2015-01-02 23:44 Jesus Reyes Assigned To => Jesus Reyes
2015-01-02 23:44 Jesus Reyes Status new => assigned
2015-01-28 12:14 Luca Olivetti Note Added: 0080636
2015-01-28 16:03 Luca Olivetti Note Added: 0080642
2015-02-20 03:23 Jesus Reyes Fixed in Revision => 47911
2015-02-20 03:23 Jesus Reyes LazTarget => 1.4
2015-02-20 03:23 Jesus Reyes Note Added: 0081273
2015-02-20 03:23 Jesus Reyes Status assigned => resolved
2015-02-20 03:23 Jesus Reyes Fixed in Version => 1.5 (SVN)
2015-02-20 03:23 Jesus Reyes Resolution open => fixed
2015-02-20 03:23 Jesus Reyes Target Version => 1.4
2015-02-20 16:46 Luca Olivetti Note Added: 0081286
2015-03-03 01:15 Jesus Reyes Note Added: 0081583
2015-04-22 11:05 Luca Olivetti Note Added: 0083106
2015-04-22 13:25 Jesus Reyes Note Added: 0083111
2015-04-22 14:14 Luca Olivetti Note Added: 0083113
2015-04-22 14:14 Luca Olivetti Status resolved => closed