?
Solved

How can I make a Treeview with multi-checkbox selection

Posted on 1998-07-14
17
Medium Priority
?
367 Views
Last Modified: 2010-04-04
I like very much the treeview object, but I would like to add one additionnal
feature to it.  Imagine a regular treeview with expand and collapse icons.
When you select one or multiple nodes, you have an additionnal checkbox icon beside
the expand and collapse.  So you can save only those selected with the checkbox.

 [  ]-[+]-Project 1
       |
 [X]-[-]-Project 2
          |
        [  ]-[+]-Application 1
               |
        [X]-[-]-Application 2      
0
Comment
Question by:sylvainl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +4
17 Comments
 

Author Comment

by:sylvainl
ID: 1357908
Edited text of question
0
 

Expert Comment

by:nileq
ID: 1357909
Hi sylvainl:
That's not an easy question. You would have to create a new component derived out of TCustomTreeView, and modify the TTreeNode object. Adding the property TTreeNode.Checked isn't verry difficult but adding the graphic capabileties sertainly demands attention.
I'll see what I can do, if I have the time :)

0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1357910
The TTreeView component supports another image which should work.  Look up "StateImages" in the help file.  From Delphi's help file: "The state image appears as an additional image to the left of the item's icon."

Cheers,
JB
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Matvey
ID: 1357911
You don't have to make them yourself - there are already some trees like this:

http://bes.trendline.co.il/torry/vcl/lbcb/chkoutl.zip
"Checkoutline is just the same as the standard outline control, but has the ability to check the items."

http://bes.trendline.co.il/torry/vcl/lbcb/mstree.zip
"A TreeView that is capable of multi-selecting." (Can be the same as checkboxes...)

http://bes.trendline.co.il/torry/vcl/lbcb/treent10.zip
"TreeNT is much enhanced treeview control, which is really fast and has many new features like checkboxes, auto scrolling, hot tracking, single expand, node hints and much more."
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357912
http://bes.trendline.co.il/torry/vcl/lbcb/outlplus.exe
"Allows you to specify different glyphs for each node in the outline."
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357913
Hi all ... everything is said at the moment.
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1357914
I would just make a glyph of a checkbox and use an overlay of a check.  Check out TImageList and overlays...

Rick
0
 
LVL 10

Accepted Solution

by:
Lischke earned 200 total points
ID: 1357915
Hi sylvainl

I'm the aouthor of TreeNT mentioned on this page and I managed to have checkboxes by listening to mouse down events and updating the stateimage. You can do it simpler.

Write an event handler for OnCollapsed and OnExpanded and use this to update a specific StateImage icon:

procedure TMainForm.TreeView1Collapsed(Sender: TObject; Node: TTreeNode);
begin
  Node.StateIndex:=ckCheckEmpty;
end;

where you define some constants like:

const ckEmpty         = 0; //: an empty image (state index must be > 0)
      ckCheckEmpty    = 1; //: an empty checkbox
      ckCheckChecked  = 2; //: a checkbox with a cross
      ckCheckDisabled = 3; //: a grayed and empty checkbox
      ckCheckGrayed   = 4; //: a grayed checkbox with a cross
      ckRadioEmpty    = 5; //: an empty radio button (circle)
      ckRadioChecked  = 6; //: a radio button with a filled circle
      ckRadioDisabled = 7; //: a grayed and empty radio button
      ckRadioGrayed   = 8; //: a grayed radio button with a filled circle

which correlate directly to images in a state image list you have to create and assign to your tree.

Nodes without an state image get 0 (zero) as stateindex, so they don't reserve any space for the image.

Hope this helps,

Ciao, Mike
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357916
Hi Mike, I guess component writrers have their fans too ;-) So I'm one. Good thing someone plants trees here :)
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1357917
Hi Matvey,

I'm pleased to read that...:-) Well, TreeNT is going to be used in lots of (even commercial) products soon. BTW: Version 2.1 is almost ready. If anyone wants a free copy, just send a mail...

Ciao, Mike
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357918
Sure, I'd love to receive the new ver. Have you seen the Eugine Mayevski tree? BWPack? A good one too. I know it because I know Eugine... (http://bes.trendline.co.il/torry/vcl/packs/bwpack.zip)

bosism@netvision.net.il (my email)
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357919
Mike, can you send a demo too? Tom.Deprez@uz.kuleuven.ac.be 10x!
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357920
Zif, Mike, the BWPack also contains lots of cool stuff, a tree I mean. My advice...
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357921
thanks, matvey, I'll a look.
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1357922
Matvey, ZifNab,

the code is on the way to your mail addresses.

I'd also a lokk at the BWPack, but the tree is without source, so it is not useful for me.

Ciao, Mike
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357923
Thank you very much Lischke.

Forgot to mention... Somebody already looked at the TeeTree? New component form TeeChart? Zif.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357924
Thanks! I'll look at it right away.

BWPack - I think it's with sources. You can email the author of course if there are no sources inside - what's the reason to hide them if it's freeware anyway?
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question