Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3214852
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:06:33+00:00 2026-05-17T15:06:33+00:00

I am trying to create a treeview that looks something like the following: Parent

  • 0

I am trying to create a treeview that looks something like the following:

Parent

|__Child1

|__ __ __ O Grandchild1

|__ __ __ O Grandchild2

|__Child2

|__ __ __ O Grandchild3

|__ __ __ O Grandchild4

I am using vb.net in Visual Studio 2008. Any insights as to how I can accomplish this will be very much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:06:34+00:00Added an answer on May 17, 2026 at 3:06 pm

    You cannot have radio buttons in a TreeView, only checkboxes.

    A solution would be to make the checkboxes behave like radio buttons:

    Private Sub TreeView1_AfterCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
        If e.Node.Checked Then
            If e.Node.Level = 2 Then
                For Each node As TreeNode In e.Node.Parent.Nodes
                    If node IsNot e.Node Then
                        node.Checked = False
                    End If
                Next
            Else
                e.Node.Checked = False
            End If
        End If
    End Sub
    

    The e.Node.Level = 2 check makes sure only grandchild nodes behave like radio buttons.

    Set the TreeView’s CheckBoxes property to True to enable checkboxes.

    This is an example of how to change text style of selected nodes and its parents:

    Private Sub TreeView1_BeforeSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeSelect
        If TreeView1.SelectedNode IsNot Nothing Then
            MakeSelected(TreeView1.SelectedNode, False)
        End If
        MakeSelected(e.Node, True)
    End Sub
    
    Private Sub MakeSelected(ByVal node As TreeNode, ByVal selected As Boolean)
        Dim SelectedFont As New Font(TreeView1.Font, FontStyle.Bold)
        node.NodeFont = IIf(selected, SelectedFont, TreeView1.Font)
        node.ForeColor = IIf(selected, Color.Blue, TreeView1.ForeColor)
    
        If node.Parent IsNot Nothing Then
            MakeSelected(node.Parent, selected)
        End If
    End Sub
    

    It recursively changes the text style of the selected node and its parents and sets it back to the TreeView’s default style when the selection changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to create a 'jsTree' treeview that gets it's data from a .Net
I am trying create a layout. There are several inner layouts that should like
I am trying to create a treeview like structure from JSON data . Structure
I am trying to determine the best way to create a treeview list in
I'm trying to catch a double-click event in a TreeView's empty area to create
I'm trying to create treeview menu where any click on an node would then
I am trying to create a TreeView nested structure with the use of self
I am trying to create a drop down control that is made up of
I'm trying out jstree, the jquery plugin to create a treeview. It works fine,
I am trying to create a treeview dynamically using c# and asp.net. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.