Click here to Skip to main content
15,885,767 members
Articles / Desktop Programming / Windows Forms

Vista Style Address Bar for .NET 2.0/WinForms

Rate me:
Please Sign up or sign in to vote.
4.77/5 (12 votes)
10 Apr 2010CPOL2 min read 71.1K   2.4K   83  
WinForms version of the Vista style address bar that can be extended to support more than just browsing the file system.
#region Using Statements

#region .NET Namespaces

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

#endregion

#region Custom Namespaces

using AddressBarExt.Controls;
#endregion

#endregion

namespace AddressBarExt
{
    /// <summary>
    /// Basic form that demos the AddressBarExt control.
    /// 
    /// This code is very messy, jsut made for demonstration purposes :)
    /// 
    /// -James Strain
    /// </summary>
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            //initialize the bar
            this.AdBar.InitializeRoot(new FileSystemNode());
        }

        private void AdBar_SelectionChange(object sender, NodeChangedArgs nca)
        {
            this.rtb_path.Text = (String)nca.OUniqueID;
        }

        private void btn_c_Click(object sender, EventArgs e)
        {
            this.AdBar.InitializeRoot(new FileSystemNode("C:\\",null));
            this.rtb_path.Text = "C:\\";
        }

        private void btn_d_Click(object sender, EventArgs e)
        {
            //get the root node
            IAddressNode root = this.AdBar.RootNode;

            //search the child nodes, non-recursivly
            this.AdBar.CurrentNode = root.GetChild(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), false);
        }

        private void AdBar_NodeDoubleClick(object sender, NodeChangedArgs nca)
        {
            this.rtb_path.Text = (String)nca.OUniqueID;


            System.Diagnostics.ProcessStartInfo exploreTest = new System.Diagnostics.ProcessStartInfo();
            exploreTest.FileName = "explorer.exe";
            exploreTest.Arguments = (String)nca.OUniqueID;
            System.Diagnostics.Process.Start(exploreTest);

        }

        private void btn_fake_Click(object sender, EventArgs e)
        {
            this.AdBar.CurrentNode = new FileSystemNode("D:\\", null);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions