Advertisement Jump to content
Sign in to follow this  

C# Treeview with (partial) CheckBoxes

This topic is 4508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm looking at creating a program (in C#) that basically lists the subdirectories of a specified root directory. When the subdirectory contains one or more files that meet a certain criteria (e.g. are *.bat files), you can choose that the file will be run (you can only run one file from a subdirectory, using radio button selection). That bit's not a problem. What I'd like to do is put a checkbox next to the directories that contain the files so that you can tick the ones that you'd want to run. I could set the CheckBoxes property of the treeview, but that would display next to every node and I'd only want to give the option of ticking the directories with the relavant fies in them. For example, say I have the following folder/file structure:
(Note: the files would not be displayed in the treeview, they would show up in a seperate control when the directory is selected). I'd only want checkboxes next to SubDirectory1 and Directory2. Is this a simple property that I'm missing or would I need to write a custom control to do this? I'm not sure I explained that very well... Thanks in advance for any help or advice, PhilHalf

Share this post

Link to post
Share on other sites
Unfortunately, MS didn't expose this functionality in the C# TreeView for some reason (it may be in Framework 2.0, but I don't think so). Who knows why... it's incredibly common and useful (and trivial to implement).

Fortunately, lots of people have tackled this. Don't rewrite it, find one over at CodeProject or a similar site. A quick search found me this one:

This may be the one I used in the past... regardless, I definitely used one off that site (an excellent C# resource) and it works fine.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!