Solved

How can I make a Treeview with multi-checkbox selection

Posted on 1998-07-14
17
339 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
  • 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
 
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 100 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi with SQL Natvie Client 15 85
my delphi exe application have  problem with windows explorer ! 12 80
Delphi application Soap connection 5 96
Delphi XE10 Round Image 2 76
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now