Tree view with specific field from json

Surya P Singh 21 Reputation points
2022-03-30T22:20:41.147+00:00

I am developing an winform application using C#.
In this application in treeview control I will be showing question and subquestions in tree structure. Source of question and sub-question will be a some specific field in a JSON.

On click of a question , list of all sub-question will be displayed in treeview and Rich textbox control. Onclick of a subquestion corresponding data and fields of subquestion node will be display in Richtextbox control and user will be allowed to edit it and save data to JSON. In tree view no technical field from JSON should be displayed. For a selected node in treeview, in richtextbox Control Complete node should be displayed along with its Childrens. User will be allowed to add a new questions as well as user can add new subquestion. all of this needs to be saved in JSON.
To better understand it

I have a below JSON (Source)

{  
  "Name": "General Health",  
  "Version": "1.2",  
  "abcd": "xy1z",  
  "NameSpace": "testing",  
  "Sections": [  
    {  
      "Name": "Height",  
      "Nodes": [  
        {  
          "Actions": [],  
          "Name": "4604",  
          "Text": "What is your exact height in cms ?",  
          "HelpText": null,  
          "Tag": "Whatisyourexactheightincms4604",  
          "IsRoot": true,  
          "IsOptional": false  
        },  
        {  
          "Actions": [],  
          "Name": "4605",  
          "Text": "What is your exact height in feet and inches ?",  
          "HelpText": null,  
          "Tag": "Whatisyourexactheightinfeetandinches4605",  
          "IsRoot": true,  
          "IsOptional": false  
        }  
      ],  
      "IsRoot": true  
    },  
    {  
      "Name": "weight",  
      "Nodes": [  
        {  
          "Actions": [],  
          "Name": "5604",  
          "Text": "What is your exact weight in pounds ?",  
          "HelpText": null,  
          "Tag": "Whatisyourexactweightinpounds5604",  
          "IsRoot": true,  
          "IsOptional": false  
        },  
        {  
          "Actions": [],  
          "Name": "5605",  
          "Text": "What is your exact weight in kgs ?",  
          "HelpText": null,  
          "Tag": "Whatisyourexactweightinkgs5605",  
          "IsRoot": true,  
          "IsOptional": false  
        }  
      ],  
      "IsRoot": true  
    }  
  ]  
}  

In this for each Section's 'Name' will become Questions and Node's Text field will become Sub-Question. so TreeView will be like below json

{  
  "Name": "General Health",  
  "Version": "1.2",  
  "abcd": "xy1z",  
  "NameSpace": "testing",  
  "Section": [  
    {    
	"Question1": "height",     
      "SubQuestion": [  
        {                    
           "SubQuestion1": "What is your exact height in cms ?"            
        },  
        {            
           "SubQuestion2": "What is your exact height in feet and inches ?"           
        }  
      ]  
        
    },  
    {  
      "Question2": "weight",  
      "SubQuestion": [  
        {            
          "SubQuestion1": "What is your exact weight in pounds ?"           
        },  
        {           
          "SubQuestion2": "What is your exact weight in kgs ?"            
        }  
      ]  
        
    }  
  ]  
}  

So challenge here is to extract a required json from source json and keeping treeview editable as well. Any idea will be helpful.
below is treeview
188591-new.png

below is richtextbox control

188553-new2.png

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,401 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,291 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,125 questions
{count} votes