简体   繁体   中英

Creating Settings form using TreeView in C#

I am developing the settings form for the software developed in C#. I was looking at how different software have implemented their settings form.

In most of the cases that I came across, they seem to be using Treeview on the left pane of the form and configuration settings on the right pane.

Ref URL : http://2.bp.blogspot.com/-nMfQoLurxwM/UDXfiZKd4DI/AAAAAAAAAME/IRf6kmxay4w/s1600/bild1.jpg

I was wondering, how the different controls are designed/displayed on the right pane. Do they hide all the controls depending which node is selected in the TreeView something like this :

   if (treeView1.SelectedNode == treeView1.Nodes[0])
        {
            this.groupBox1.Visible = true;
            this.button1.Visible = true;
            this.textBox1.Visible = true;
            this.textBox2.Visible = true;
            this.label1.Visible = true;
            this.label2.Visible = true;
            this.label3.Visible = true;

        }
        else
        {
            this.groupBox1.Visible  = false;
            this.button1.Visible    = false;
            this.textBox1.Visible   = false;
            this.textBox2.Visible   = false;
            this.label1.Visible     = false;
            this.label2.Visible     = false;
            this.label3.Visible     = false;

        this.groupBox2.Visible  = true;
            this.button2.Visible    = true;
            this.textBox3.Visible   = true;
            this.textBox3.Visible   = true;
            this.labe4.Visible     = true;
            this.label5.Visible     = true;
            this.label6.Visible     = true;

           // bool success = selectColor();
        }

Is my understanding correct ? Or do we have a better design approach for creating a settings form.

Thanks

You can create panels and swap their visibility. So depending on what setting is selected, you fill the controls and display a particular panel.

There are many ways but you can have a combination of Treeview control and Tab control. Check this link . This may help. In this link, the tabpages of tabcontrol are used as treeview control nodes.

Have a look at this link too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM