Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Treeview in windows application

Treeview in windows application

Scheduled Pinned Locked Moved C#
helptutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arun kumar Gautam
    wrote on last edited by
    #1

    Hi, I have a problem with treeview in windows application for example i have a treeview as follows with checkboxes:- Root0 Node0 Node1 Root1 Node2 Node3 now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked and if i check on root0 thn both nodes with be checked automatically i m trying soo hard but m found nothing still, can anyone help me with it

    S A L 3 Replies Last reply
    0
    • A Arun kumar Gautam

      Hi, I have a problem with treeview in windows application for example i have a treeview as follows with checkboxes:- Root0 Node0 Node1 Root1 Node2 Node3 now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked and if i check on root0 thn both nodes with be checked automatically i m trying soo hard but m found nothing still, can anyone help me with it

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      Firstly I would suggest that you explain what you have done more, possibly show some code as we can then potentially see where the problem is rather than guess. Secondly I wouldn't post your problem multiple times as this is condsidered rude / bad form.

      Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

      1 Reply Last reply
      0
      • A Arun kumar Gautam

        Hi, I have a problem with treeview in windows application for example i have a treeview as follows with checkboxes:- Root0 Node0 Node1 Root1 Node2 Node3 now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked and if i check on root0 thn both nodes with be checked automatically i m trying soo hard but m found nothing still, can anyone help me with it

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        Please don't repost. Modify the original question if you have to.

        Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

        1 Reply Last reply
        0
        • A Arun kumar Gautam

          Hi, I have a problem with treeview in windows application for example i have a treeview as follows with checkboxes:- Root0 Node0 Node1 Root1 Node2 Node3 now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked and if i check on root0 thn both nodes with be checked automatically i m trying soo hard but m found nothing still, can anyone help me with it

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Arun kumar Gautam wrote:

          now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked
           
          and if i check on root0 thn both nodes with be checked automatically
          i m trying soo hard but m found nothing still, can anyone help me with it

          I'd expect this behaviour; can you explain why you think it's wrong?

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          A 1 Reply Last reply
          0
          • L Lost User

            Arun kumar Gautam wrote:

            now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked
             
            and if i check on root0 thn both nodes with be checked automatically
            i m trying soo hard but m found nothing still, can anyone help me with it

            I'd expect this behaviour; can you explain why you think it's wrong?

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            A Offline
            A Offline
            Arun kumar Gautam
            wrote on last edited by
            #5

            wel m now able to resolve it by using #region TreeView private void CheckChildNode(TreeNode currNode) { //set the children check status to the same as the current node bool checkStatus = currNode.Checked; foreach (TreeNode node in currNode.Nodes) { node.Checked = checkStatus; CheckChildNode(node); } } private void CheckParentNode(TreeNode currNode) { TreeNode parentNode = currNode.Parent; if (parentNode == null) return; parentNode.Checked = true; foreach (TreeNode node in parentNode.Nodes) { if (!node.Checked) { parentNode.Checked = false; break; // TODO: might not be correct. Was : Exit For } } CheckParentNode(parentNode); } #endregion

            private void menuCollection_AfterCheck(object sender, TreeViewEventArgs e)
            {
            menuCollection.AfterCheck -= menuCollection_AfterCheck;
            CheckChildNode(e.Node);
            CheckParentNode(e.Node);
            menuCollection.AfterCheck+=menuCollection_AfterCheck;
            }

            hope this code helps someone in future

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups