Tag Archives: TreeView

Initialize a TreeView control to display a directory hierarchy in C#

This example adds the following LoadFromDirectory extension method to the TreeView control. // Initialize the TreeView from a directory, // its subdirectories, and their files. public static void LoadFromDirectory(this TreeView trv, string directory, int folder_img, int file_img) { DirectoryInfo dir_info … Continue reading

Posted in controls, directories, extension methods, files, user interface | Tagged , , , , , , , , , , , , , | Leave a comment

Check a TreeView subtree in C#

Sometimes it’s useful to let the user select a TreeView subtree by clicking on a higher-level node. Then the user can deselect individual nodes within the subtree if desired. For example, in the picture shown here I checked the Dinner … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , , , , , | 4 Comments

Display context menus for TreeView items in C#

This example displays different context menus when you right-click on different kinds of nodes in a TreeView control. In this example, different nodes represent factories, groups, or individuals. Different node types display different context menus. When it starts, the program … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , , , | Leave a comment

Enumerate TreeView nodes in C#

The previous two posts show two ways you can enumerate TreeView nodes that are checked. The idea is to recursively crawl over the tree’s nodes and pick out the checked ones. Unfortunately that method isn’t easily extendable. For example, if … Continue reading

Posted in algorithms, controls, recursion, user interface | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Yield checked TreeView nodes in C#

The previous example used recursion to traverse the nodes in a TreeView control and fill a list with the nodes that are checked. This example uses a slightly different approach. It traverses the TreeView control’s nodes and uses the yield … Continue reading

Posted in algorithms, controls, recursion, user interface | Tagged , , , , , , , , , , , , , , | Leave a comment

Make a list of checked TreeView nodes in C#

If you set a TreeView control’s CheckBoxes property to true, then the control displays boxes that the user can check to select nodes. In that case you will probably need to find the checked TreeView nodes at some point. Strangely … Continue reading

Posted in algorithms, controls, recursion, user interface | Tagged , , , , , , , , , , , , , | Leave a comment

Display tooltips for TreeView nodes in C#

At design time, I added a TreeView control to the form. I also added an associated ImageList control to hold images for the TreeView control’s nodes, and I set the TreeView control’s ImageList property to the ImageList control. Finally I … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , , , , , , | 1 Comment

Display a form’s control hierarchy in C#

This example displays the control hierarchy for a form. It’s actually relatively simple. Some controls can contain other controls. For example, a form is a control and it contains all of a Windows Forms application’s controls. Similarly Panel, TableLayoutPanel, SplitContainer, … Continue reading

Posted in controls, forms | Tagged , , , , , , , , , , , , | Leave a comment

Load a WPF TreeView control from an XML file in C#

The post Load a TreeView control from an XML file in C# explains how you can display XML data in a Windows Forms TreeView control. This example does something similar for a WPF project. In keeping with the unofficial WPF … Continue reading

Posted in controls, wpf, XAML, XML | Tagged , , , , , , , , , , , , | 3 Comments

List Dropbox directories and files in C#

Dropbox is a file sharing service. The free Basic version lets you easily share up to 2 GB of files across the internet. The $9.99/month Pro version gives you up to 1 TB and the $15.00/month Business version gives you … Continue reading

Posted in directories, files, system, tools | Tagged , , , , , , , , , , , , , , | Leave a comment