Project JEDI - Issue Tracker - JEDI VCL
Viewing Issue Advanced Details
6540 00 JVCL Components minor always 2016-12-09 14:24 2019-01-25 12:07
CDametto  
 
normal  
feedback 3.48  
open  
none    
none  
0006540: Horizontal reset of dbgrid scrollbar by moving a column
In a DBGrid with dgRowSelect in Options, TitleButton = True and TitleButtonAllowMove = True, whether the horizontal scrollbar is present and you move a column at the right end, the grid is repositioned to the start left.
This is my correction, in the file JvDBGrid.pas near the bottom of the MouseUp procedure...
Original block:

  if (Button = mbLeft) and (FGridState = gsColSizing) then
  begin
    ALeftCol := LeftCol;
    inherited MouseUp(Button, Shift, X, Y);
    if (dgRowSelect in Options) then
      LeftCol := ALeftCol;
    if Assigned(OnColumnResized) then
      OnColumnResized(Self, FSizingIndex + Byte(not (dgIndicator in Options)) - 1,
        ColWidths[FSizingIndex]);
  end
  else
    inherited MouseUp(Button, Shift, X, Y);
  DoAutoSizeColumns;


I just developed the penultimate row:

  if (Button = mbLeft) and (FGridState = gsColSizing) then
  begin
    ALeftCol := LeftCol;
    inherited MouseUp(Button, Shift, X, Y);
    if (dgRowSelect in Options) then
      LeftCol := ALeftCol;
    if Assigned(OnColumnResized) then
      OnColumnResized(Self, FSizingIndex + Byte(not (dgIndicator in Options)) - 1,
        ColWidths[FSizingIndex]);
  end
  else
  begin
    SI.cbSize := SizeOf(SI); //
    SI.fMask := SIF_POS; // Store scrollbar position
    GetScrollInfo(Handle, SB_HORZ, SI); //
    LockWindowUpdate(Handle);
    try
      inherited MouseUp(Button, Shift, X, Y);
      Perform(WM_HSCROLL, MakeWParam(SB_THUMBPOSITION, SI.nPos), 0); //Repos
    finally
      LockWindowUpdate(0);
    end;
  end;
  DoAutoSizeColumns;
zip file icon Demo.zip [^] (6,546 bytes) 2019-01-25 10:49
zip file icon Demo_corrected.zip [^] (54,752 bytes) 2019-01-25 12:07
Issue History
2016-12-09 14:24 CDametto New Issue
2016-12-28 16:35 CDametto Note Added: 0021407
2018-07-18 15:52 obones Note Added: 0021521
2018-07-18 15:52 obones Status new => feedback
2019-01-25 10:49 CDametto File Added: Demo.zip
2019-01-25 10:53 CDametto Note Added: 0021601
2019-01-25 12:04 CDametto Issue Monitored: CDametto
2019-01-25 12:04 CDametto Issue End Monitor: CDametto
2019-01-25 12:07 CDametto File Added: Demo_corrected.zip

Notes
(0021407)
CDametto   
2016-12-28 16:35   
The variable SI is declared locally in the procedure as SI: TScrollInfo;
(0021521)
obones   
2018-07-18 15:52   
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.
(0021601)
CDametto   
2019-01-25 10:53   
The issue is still present in jvcl 3.50 with Delphi 10.3 rio