Jump to content
  • Advertisement
Sign in to follow this  
PhilHalf

C# Treeview with (partial) CheckBoxes

This topic is 4413 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:
C:
  Directory1
    SubDirectory1
      File1.bat
    SubDirectory2
  Directory2
    File3.bat
(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
Advertisement
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:

http://www.codeproject.com/cs/miscctrl/TriStateTreeViewSubmissio.asp

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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!