Files and Folders in Treeview with Checkbox

J

Jay

Anyone know where I might find an example on creating a treeview containing
the entire directory structure and files with checkboxes to allow selection
of directory and/or file? Are there controls like this in VStudio 2005
(there was in Studio 6)? I understand there are third party controls that
do this but I'd like to do it on my own.

Thanks.
 
J

Jeff Gaines

Anyone know where I might find an example on creating a treeview
containing the entire directory structure and files with checkboxes
to allow selection of directory and/or file? Are there controls like
this in VStudio 2005 (there was in Studio 6)? I understand there are
third party controls that do this but I'd like to do it on my own.


How complex do you want it to be?

There is a file manager app on my web site (source code only) at:

http://www.jgaines.me.uk/html/jeff_s_filer.html

it makes extensive use of the API though, you would need to set some
flags to show files in the TV, they currently show in the ListView. I
have a horrible feeling it has a memory leak, be great if you can find
it :)

I also have a similar app which I could email to you which tries to use
just native .NET calls, again the TV shows folders and the LV shows
folders/files. It does use the API for some calls like TV sorting and
system icons but I haven't been able to find native code to do that.

They are both in C# and neither has check boxes but the rest of the
stuff you need is there as a base.
 
J

Jay

Thanks a lot. Really all I'm looking for is a .net way of selecting folders
and files in a treeview. I'm wanting to create my own backup app and only
need the ability to select folders and/or files. Would you happen to have
something like that? I appreciate the help.
 
J

Jeff Gaines

Thanks a lot. Really all I'm looking for is a .net way of selecting
folders and files in a treeview. I'm wanting to create my own backup
app and only need the ability to select folders and/or files. Would
you happen to have something like that? I appreciate the help.


The one I have here starts with drive letters and works its way through
folders using .NET calls. It doesn't show Control Panel or stuff like
that, just anything that has a drive letter. You'd need to lift the
show files code from the LV and graft it on to the TV. Actually getting
folder/file information on to a TreeView is straightforward, and if you
keep the path in the Tag property of each node you can identify what
has been selected. The killer with a TV is finding nodes
programatically :)
 
J

Jay

Excellent, thanks a lot. I've seen your example and am in the process of
tryint to convert to VB.NET. I appreciate the feedback.
 
J

Jay

What I'm having the most difficult time with is the tri mode selection of
the treeview. For examply, if you select a file it should grey out the
parent, etc. Or if you select an entire directory it should place a check
in all subs and files.
 
J

Jeff Gaines

What I'm having the most difficult time with is the tri mode
selection of the treeview. For examply, if you select a file it
should grey out the parent, etc. Or if you select an entire
directory it should place a check in all subs and files.

I've never used check boxes in a TV, I suspect you will have to pick up
the check/click event and check the sub nodes yourself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top