[solved] Deselect items in treeview? lazarus / 31-LCL ---------------------------------------------------------------------- piola · 2019-01-20 09:23 Hello, I'm using a TTreeView component with MultiSelect=TRUE and MultiSelectStyle=[msControlSelect, msShiftSelect, msVisibleOnly]. I would appreciate if someone tells me how I can deselect a selected item. My intuitive approach was to set TreeView.Items[n].Selected := FALSE, but this does nothing. I have been looking for a remove or delete method of the TreeView.Selections, but there doesn't seem to be one. In contrast to Delphi, there seems to be no TreeView.Delete method either. So what it is the prefered way of deselecting a TreeView node? Thanks for any help! ---------------------------------------------------------------------- Blaazen · 2019-01-20 11:48 There is method ClearSelection();. ---------------------------------------------------------------------- piola · 2019-01-20 12:20 Yes, thanks, but this removes the selection of all nodes. I want to deselect only some nodes. ---------------------------------------------------------------------- Blaazen · 2019-01-20 13:35 This works (I looked how is ClearSelection implemented): 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 procedure TForm1.Button1Click(Sender: TObject);var ANode, OldNode: TTreeNode;begin  ANode := TreeView1.GetFirstMultiSelected;  while assigned(ANode) do    begin      OldNode := ANode;      ANode := ANode.GetNextMultiSelected;      if OldNode.Text[1] = 'G' then OldNode.MultiSelected := false;    end;  if TreeView1.Selected.Text[1] = 'G' then TreeView1.Selected:=nil;end;This deselects all nodes beginning with 'G'. Note: (Main) selected node and the other mutliselected nodes are handled separately, therefore, you need to apply condition separately too. ---------------------------------------------------------------------- piola · 2019-01-20 15:40 Great! Thank you very much!