TreeView: How to discontinuous multiselect items with the keyboard? lazarus / 31-LCL ---------------------------------------------------------------------- RAW · 2020-02-06 12:56 I don't know how to discontinuous multiselect items inside a treeview with the keyboard. To do this with the mouse works out of the box. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i UNIT Unit1;{$MODE OBJFPC}{$H+}INTERFACE USES  Classes, SysUtils, Forms, Controls, Graphics, ComCtrls, StdCtrls, LCLType; TYPE  TForm1 = Class(TForm)    TV    : TTreeView;    btnNew: TButton;    btnDel: TButton;    Procedure FormCreate  (Sender: TObject);    Procedure btnNewClick (Sender: TObject);    Procedure btnDelClick (Sender: TObject);    Procedure FormKeyDown (Sender: TObject; Var Key: Word; Shift: TShiftState);  End; VAR  Form1: TForm1; IMPLEMENTATION{$R *.LFM} Procedure TForm1.FormCreate(Sender: TObject);Begin  DoubleBuffered:= True; // classic theme   TV.Color     := clWhite;  TV.Font.Color:= clBlack;   TV.Options:=  [tvoAllowMultiselect, tvoAutoItemHeight, tvoHideSelection, tvoThemedDraw];   TV.MultiSelectStyle:= [msControlSelect, msShiftSelect];  Position:= poDesktopCenter;End; Procedure TForm1.btnNewClick(Sender: TObject);Var i: Integer;Begin  i:= TV.Items.Count;  TV.Items.Add(Nil,'MY NICE NEW ITEM '+IntToStr(i));End; Procedure TForm1.btnDelClick(Sender: TObject);Var i: Integer; Node, NodeSelFirst, NodeSelLast: TTreeNode;Begin  If TV.SelectionCount = 0 Then Exit;   // check the selection direction  NodeSelFirst:= TV.Items.GetSelections(0);  NodeSelLast := TV.Items.GetSelections(TV.Items.SelectionCount-1);   If NodeSelFirst.Index > NodeSelLast.Index   Then Node:= NodeSelLast.GetPrev   Else Node:= NodeSelFirst.GetPrev;   If TV.Items.Count > 0  Then    Begin      TV.BeginUpdate;        // delete selected items        For i:= 0 To TV.SelectionCount-1        Do TV.Items.Delete(TV.Items.GetSelections(0));         If TV.Items.Count > 0        Then         Begin           // scroll to the last not selected item           If Node.Index = -1 Then Node:= TV.Items.GetFirstVisibleNode;           TV.Select(Node);         End;      TV.EndUpdate;    End;End; Procedure TForm1.FormKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);Begin  Case Key Of    VK_DELETE: btnDelClick(Sender);  End;End;END. ---------------------------------------------------------------------- HeavyUser · 2020-02-06 14:18 discontinue multiselect? you mean non continues blocks? As far as I remember it is not supported on a treeview only in listview and as far as I remember its control and arrows to move the focus but not the selection and space to toggle selection on the focused item. I can check with delphi later tonight if required. ---------------------------------------------------------------------- RAW · 2020-02-06 18:15 @HeavyUser: Ok, thanks, just wanted to get sure that I'm not missing or overlooking something.  I thought there is something like CTRL+SPACE similar to Windows- Explorer. Of course I can use the arrow keys to select one item and in combination with SHIFT to select a block of items, that's fine... I didn't see any second focus to handle a selection with SPACE and I thought it can be activated somewhere ...