Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003361 [JEDI VCL] 00 JVCL Components major always 2005-12-12 10:08 2006-01-05 08:02
Reporter hansverlouw3 View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.00
Summary 0003361: Get and set checkbox value in TJvTreeView
Description When a checkbox is checked, I want to check all its children as well.
But I cannot determine if a checkbox has changed.
Isn't there a property missing?

I tested with

procedure TfrmMain.JvTreeView1MouseDown(Sender: TObject;
    Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
    if TJvTreeNode(JvTreeView1.GetNodeAt(x,y)).checked then
        Panel1.Color := clGreen
    else
        Panel1.Color := clRed;
end;
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0008214)
hansverlouw3 (reporter)
2005-12-13 05:01

Found the solution myself ;-)
Use TJvCheckTreeView in stead of TJvTreeView.
TJvCheckTreeView has an event OnToggled.
By the way, note that it only behaves ok when
CheckBoxOptions.Style = cbsJVCL.

So to cascade checkbox values on toggling a node, use something like this:

procedure TfrmMain.JvTreeView1Toggled(Sender: TObject; Node: TTreeNode);
var
  i: integer;
  Child: TTreeNode;
begin
  Child := Node.getFirstChild;
  for i := 0 to Node.Count - 1 do
  begin
    TJvTreeNode(Child).Checked := TJvTreeNode(Node).Checked;
    Child := Node.GetNextChild(Child);
  end;
end;
(0008215)
hansverlouw3 (reporter)
2005-12-13 05:31

A recursive implementation of the procedure in the previous note:

procedure TfrmMain.CheckCascading(Node: TTreeNode);
var
  i: integer;
  Child: TTreeNode;
begin
  Child := Node.getFirstChild;
  for i := 0 to Node.Count - 1 do
  begin
    TJvTreeNode(Child).Checked := TJvTreeNode(Node).Checked;
    CheckCascading(Child);
    Child := Node.GetNextChild(Child);
  end;
end;


procedure TfrmMain.JvTreeView1Toggled(Sender: TObject; Node: TTreeNode);
begin
  CheckCascading(Node);
end;

- Issue History
Date Modified Username Field Change
2005-12-12 10:08 hansverlouw3 New Issue
2005-12-13 05:01 hansverlouw3 Note Added: 0008214
2005-12-13 05:31 hansverlouw3 Note Added: 0008215
2006-01-05 08:02 obones Status new => resolved
2006-01-05 08:02 obones Resolution open => fixed
2006-01-05 08:02 obones Assigned To => obones
2006-02-22 07:35 Kyle_Katarn Issue Monitored: Kyle_Katarn
2006-02-22 07:36 Kyle_Katarn Issue End Monitor: Kyle_Katarn
2010-10-30 15:52 outchy Relationship added has duplicate 0005386
2010-10-30 15:53 outchy Relationship deleted has duplicate 0005386


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker