C# Winform treeview and display UI for each node

416 views
Skip to first unread message

Ben

unread,
Jan 4, 2010, 2:16:28 PM1/4/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,

Is it possible to create a C# Winform that display a treeview on the
left hand side and a different UI form/page with textboxes and labels
for each node on the right hand side? For example, if a user click
node1, it will show a UI on the right, node2 will show another UI
design on the right.

How should I go about doing this?

Many thanks and Happy New Year.

Ben

Cerebrus

unread,
Jan 5, 2010, 4:18:53 AM1/5/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
One way could be to:

Divide your form into two separate portions using a SplitContainer.
Use container controls such as Layout panels on the right side and
load panels according to the selected node in the TreeView.

Benj Nunez

unread,
Jan 6, 2010, 7:50:28 PM1/6/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Like what Cerebrus mentioned earlier, use the panels. They will be the
"parent" of your
UI. Design your GUI using the "User Control" (right-click on your
*.csproj file, select "Add", then "New Item").


Happy coding!

Benj

Processor Devil

unread,
Jan 7, 2010, 3:08:43 AM1/7/10
to dotnetde...@googlegroups.com
Benj, why did you answer? Are you trying to get credit for the posting? :P

2010/1/7 Benj Nunez <benj...@gmail.com>

Pratiksha Saxena

unread,
Jan 5, 2010, 2:20:59 AM1/5/10
to dotnetde...@googlegroups.com
sorry i used ASP.NET


On Tue, Jan 5, 2010 at 12:32 PM, Pratiksha Saxena <pratiksh...@gmail.com> wrote:
Yes you can create a treeview that will display different UI.
Create Treeview tvList

Something like this

string xmlName="HeadLine.xml";

private void CreateTree(String xmlName)
    {
        
        XmlDocument XmlDoc = new XmlDocument();
        XmlDoc.Load(Server.MapPath("TreeXml\\" + xmlName));

        tvList.Nodes.Clear();
        foreach (XmlNode node in XmlDoc.ChildNodes[0].ChildNodes)
        {
            TreeNode tNode = new TreeNode();
            tNode.Text = node.Attributes["title"].Value;
            tNode.Value = node.Attributes["url"].Value;
           

            tvList.Nodes.Add(tNode);
        } 
    }

Eg of HeadLine.xml

<xml>
      <siteMapNode title="Phono" url="Phono.aspx" description="Phono"/>
      <siteMapNode title="Coming Up Next" url="ComingUpNext.aspx" description="ComingUpNext"/>
 </xml>


Easy ....

Pratiksha

Pratiksha Saxena

unread,
Jan 5, 2010, 2:02:40 AM1/5/10
to dotnetde...@googlegroups.com
Yes you can create a treeview that will display different UI.
Create Treeview tvList

Something like this

string xmlName="HeadLine.xml";

private void CreateTree(String xmlName)
    {
        
        XmlDocument XmlDoc = new XmlDocument();
        XmlDoc.Load(Server.MapPath("TreeXml\\" + xmlName));

        tvList.Nodes.Clear();
        foreach (XmlNode node in XmlDoc.ChildNodes[0].ChildNodes)
        {
            TreeNode tNode = new TreeNode();
            tNode.Text = node.Attributes["title"].Value;
            tNode.Value = node.Attributes["url"].Value;
           

            tvList.Nodes.Add(tNode);
        } 
    }

Eg of HeadLine.xml

<xml>
      <siteMapNode title="Phono" url="Phono.aspx" description="Phono"/>
      <siteMapNode title="Coming Up Next" url="ComingUpNext.aspx" description="ComingUpNext"/>
 </xml>


Easy ....

Pratiksha





On Tue, Jan 5, 2010 at 12:46 AM, Ben <bsw...@gmail.com> wrote:

Cerebrus

unread,
Jan 7, 2010, 10:29:56 AM1/7/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Benj was adding to my post and I believe that his statements do add
value to the advice I had given. Since I had mentioned it as just "one
way to do it", reaffirming that method says that it might be the
preferred way to do it. ;-)

On Jan 7, 1:08 pm, Processor Devil <processor.de...@gmail.com> wrote:
> Benj, why did you answer? Are you trying to get credit for the posting? :P
>

> 2010/1/7 Benj Nunez <benjnu...@gmail.com>

Benj Nunez

unread,
Jan 8, 2010, 12:14:44 AM1/8/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Nope. Of course not. I just wanted to help. Besides, I'm anticipating
that
he might ask again. :D

Benj

On Jan 7, 4:08 pm, Processor Devil <processor.de...@gmail.com> wrote:
> Benj, why did you answer? Are you trying to get credit for the posting? :P
>

> 2010/1/7 Benj Nunez <benjnu...@gmail.com>

Reply all
Reply to author
Forward
0 new messages