New to Telerik UI for WinForms? Download free 30-day trial

Getting Started with WinForms TreeView

The following tutorial will help you get started working with the RadTreeView at design time and programmatically. Topics included are: 

  • Associating breadcrumb component to the RadTreeView.

  • Using the RadTreeView designer to add and configure nodes.

  • Programmatically adding and configuring nodes.

 Getting Started Tutorial

  1. Create a new Windows Forms Application.

  2. On the form add a RadBreadCrumb and RadTreeView.

  3. In the Properties window  for the RadBreadCrumb set the DefaultTreeView property to point to the RadTreeView. The design should now look like this.

    WinForms RadTreeView Properties

  4. Drop the TelerikMetro theme form the tool box and set all controls ThemeName property to TelerikMetro.

  5. Right click the RadTreeView and select Open Property Builder from the context menu. You will see a set of buttons on the left side of the RadTreeView Property Builder and a preview of the tree view below the buttons. See Property Builder topic for a complete tour of functionality.

  6. Click the far left button (a green "Plus" button that adds nodes) three times to add three nodes.

  7. Click the first node and enter "Email Contacts" in the Text entry.

  8. Click the second node and enter "Lists" in the Text entry.

  9. Click the third node and enter "Reports" in the Text entry.

  10. Click the RadTreeView Properties tab located in the left part of the Window.

  11. Check Show Lines.

  12. Click OK to close the Property Builder.The design should now look like the screenshot below.

    WinForms RadTreeView PropertyBuilder

  13. In the form code add a "using" statement for Telerik.WinControls.UI

  14. In the form's constructor add the code appearing below the InitializeComponent() method call. This code creates new RadTreeNode objects, populates them with text and attaches them to parent nodes.


RadTreeNode node = radTreeView1.Nodes["Email Contacts"].Nodes.Add("Bob Tony");
node.Selected = true;

radTreeView1.Nodes["Email Contacts"].Nodes.Add("Sue Winchell");
radTreeView1.Nodes["Email Contacts"].Nodes.Add("Lui Sang");
radTreeView1.Nodes["Lists"].Nodes.Add("Priorities");
radTreeView1.Nodes["Lists"].Nodes.Add("Opportunities");
radTreeView1.Nodes["Lists"].Nodes.Add("Issues");

node = radTreeView1.Nodes["Reports"].Nodes.Add("June Sales");
node = radTreeView1.Nodes["Reports"].Nodes.Add("July Sales");
node = radTreeView1.Nodes["Reports"].Nodes.Add("First Quarter Summary");
node = radTreeView1.Nodes["Reports"].Nodes.Add("Second Quarter Summary");

Dim node As RadTreeNode = RadTreeView1.Nodes("Email Contacts").Nodes.Add("Bob Tony")
node.Selected = True
RadTreeView1.Nodes("Email Contacts").Nodes.Add("Sue Winchell")
RadTreeView1.Nodes("Email Contacts").Nodes.Add("Lui Sang")
RadTreeView1.Nodes("Lists").Nodes.Add("Priorities")
RadTreeView1.Nodes("Lists").Nodes.Add("Opportunities")
RadTreeView1.Nodes("Lists").Nodes.Add("Issues")
node = RadTreeView1.Nodes("Reports").Nodes.Add("June Sales")
node = RadTreeView1.Nodes("Reports").Nodes.Add("July Sales")
node = RadTreeView1.Nodes("Reports").Nodes.Add("First Quarter Summary")
node = RadTreeView1.Nodes("Reports").Nodes.Add("Second Quarter Summary")

14. Run the application.

WinForms RadTreeView Getting Started Run

See Also

Telerik UI for WinForms Learning Resources

In this article