Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006542 [JEDI VCL] 00 JVCL Components minor always 2016-12-28 16:32 2016-12-28 16:32
Reporter CDametto View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version 3.48
Summary 0006542: Horizontal reset of dbgrid scrollbar at line click when no indicator
Description In 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 Information This 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
Tags No tags attached.
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2016-12-28 16:32 CDametto New Issue


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker