View Issue Details

IDProjectCategoryView StatusLast Update
0006542JEDI VCL00 JVCL Componentspublic2019-03-06 09:45
ReporterCDamettoAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionunable to reproduce 
Product Version3.48 
Target VersionFixed in Version 
Summary0006542: Horizontal reset of dbgrid scrollbar at line click when no indicator
DescriptionIn a DBGrid with dgRowSelect=true and dgIndicator=false in Options, whether the horizontal scrollbar is present, if you are at right end and you click on a row, the grid is repositioned to the start left.
Additional InformationThis is my correction, in the file JvDBGrid.pas, in the middle of the MouseDown procedure...
Original block:

//-------------------------------------------------------------------------------
// Prevents the grid from going back to the first column when dgRowSelect is True
// Does not work if there's no indicator column
//-------------------------------------------------------------------------------
if (dgRowSelect in Options) and (Cell.Y >= TitleOffset) then
begin
  // Why do we always have to work around the VCL. If we use the original X the
  // Grid will scroll back to the first column. But if we don't use the original X
  // and goRowSizing is enabled, the user can start resizing rows in the wild.
  WasRowResizing := goRowSizing in TCustomGridAccess(Self).Options;
  try
    // Disable goRowSizing without all the code that SetOptions executes.
    TGridOptions(Pointer(@TCustomGridAccess(Self).Options)^) := TCustomGridAccess(Self).Options - [goRowSizing];
    inherited MouseDown(Button, Shift, 1, Y);
    InheritedCalled := True;
  finally
    if WasRowResizing then
      TGridOptions(Pointer(@TCustomGridAccess(Self).Options)^) := TCustomGridAccess(Self).Options + [goRowSizing];
  end;
end

I declared in the procedure var SI: TScrollInfo;
block with my correction:

//-------------------------------------------------------------------------------
// Prevents the grid from going back to the first column when dgRowSelect is True
// Does not work if there's no indicator column
//-------------------------------------------------------------------------------
if (dgRowSelect in Options) and (Cell.Y >= TitleOffset) then
begin
  // Why do we always have to work around the VCL. If we use the original X the
  // Grid will scroll back to the first column. But if we don't use the original X
  // and goRowSizing is enabled, the user can start resizing rows in the wild.
  WasRowResizing := goRowSizing in TCustomGridAccess(Self).Options;
  try
    // Disable goRowSizing without all the code that SetOptions executes.
    TGridOptions(Pointer(@TCustomGridAccess(Self).Options)^) := TCustomGridAccess(Self).Options - [goRowSizing];

    SI.cbSize := SizeOf(SI); //ADDED
    SI.fMask := SIF_POS; //ADDED
    GetScrollInfo(Handle, SB_HORZ, SI); //ADDED
    LockWindowUpdate(Handle); //ADDED
    try //ADDED
    
      inherited MouseDown(Button, Shift, 1, Y);
    
    Perform(WM_HSCROLL, MakeWParam(SB_THUMBPOSITION, SI.nPos), 0); //ADDED
    finally //ADDED
      LockWindowUpdate(0); //ADDED
    end; //ADDED

    InheritedCalled := True;
  finally
    if WasRowResizing then
      TGridOptions(Pointer(@TCustomGridAccess(Self).Options)^) := TCustomGridAccess(Self).Options + [goRowSizing];
  end;
end
TagsNo tags attached.

Activities

obones

2018-07-18 15:47

administrator   ~0021505

Could you check if the issue is still present in the latest GIT content? If yes, please provide the zipped sources of an application showing this.

CDametto

2019-01-25 12:20

reporter   ~0021603

Now it seems to work. Thank you.

Issue History

Date Modified Username Field Change
2016-12-28 16:32 CDametto New Issue
2018-07-18 15:47 obones Note Added: 0021505
2018-07-18 15:47 obones Status new => feedback
2019-01-25 12:20 CDametto Note Added: 0021603
2019-03-06 09:45 obones Status feedback => resolved
2019-03-06 09:45 obones Resolution open => unable to reproduce
2019-03-06 09:45 obones Assigned To => obones