Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
THTMLTreeView
How to have all Child items checked or unchecked depending on the parent check state
How to have all Child items checked or unchecked depending on the parent check state
This is a code snippet that demonstrates this applied to a default THTMLTreeView on the form:
procedure TForm4.FormCreate(Sender: TObject); var tn,sn: TTreeNode; begin tn := htmltreeview1.Items.Add(nil,'Parent node'); htmltreeview1.SetNodeCheck(tn, false); sn := htmltreeview1.Items.AddChild(tn,'Child 1'); htmltreeview1.SetNodeCheck(sn, false); sn := htmltreeview1.Items.AddChild(tn,'Child 2'); htmltreeview1.SetNodeCheck(sn, false); sn := htmltreeview1.Items.AddChild(tn,'Child 3'); htmltreeview1.SetNodeCheck(sn, false); tn := htmltreeview1.Items.Add(nil,'Parent node'); htmltreeview1.SetNodeCheck(tn, false); end; procedure TForm4.HTMLTreeview1CheckBoxClick(Sender: TObject; Node: TTreeNode; Check: Boolean); var i: integer; sn: TTreeNode; begin sn := Node.getFirstChild; while assigned(sn) do begin Htmltreeview1.SetNodeCheck(sn,check); sn :=sn.getNextSibling; end; end;