Mega Code Archive

 
Categories / Delphi / Examples
 

How can i modify a treeview items height

Question: How can I modify a TreeView item's height? Answer: Simply send a message TVM_SETITEMHEIGHT to the treeview control. The first parameter (word parameter, aka 'wParm') specifies the new height of every item in the tree view, measured in pixels. Note these restrictions: this will affect all items in the treeview control heights less than 1 will be set to 1. if the height is not even and the tree-view control does not have the TVS_NONEVENHEIGHT style, this value will be rounded down to the nearest even value. if the height is -1, the control will revert to using its default item height. uses CommCtrl; procedure SetTreeViewItemHeight(aTreeView: TTreeView; iItemHeight: Word); begin { SetTreeViewItemHeight } aTreeView.Perform(TVM_SETITEMHEIGHT, iItemHeight, 0); end; { SetTreeViewItemHeight } procedure TForm1.Button1Click(Sender: TObject); begin { TForm1.Button1Click } SetTreeViewItemHeight(TreeView1, 30); end; { TForm1.Button1Click } //..