Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can I make a Treeview with multi-checkbox selection

Posted on 1998-07-14
17
Medium Priority
?
376 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
Technology Partners: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

636 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