Ctrl + End behavior TVirtualStringTree

When the user presses Ctrl + End, VirtualStringTree jumps to the end vertically, which is fine, but also horizontally. I do not want it to end horizontally. The horizontal scroll should be positioned as is.

How to say it?

Thank.

+3
source share
1 answer

The handler OnKeyActionin the following code checks whether the buttons are pressed CTRL + HOMEor CTRL + END, and if so, it scrolls (only vertically) either up or down, depending on what was pressed.

procedure TForm1.VirtualTreeKeyAction(Sender: TBaseVirtualTree;
  var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean);
begin
  if (ssCtrl in Shift) then
  case CharCode of
    VK_HOME:
    begin
      DoDefault := False;
      VirtualTree.ScrollIntoView(VirtualTree.GetFirst, False);
    end;
    VK_END:
    begin
      DoDefault := False;
      VirtualTree.ScrollIntoView(VirtualTree.GetLast, False);
    end;
  end;
end;
+4
source

All Articles