zoukankan      html  css  js  c++  java
  • Windows 7样式地址栏(Address Bar)控件实现

    介绍

    从Vista开始,地址栏就有了很大的改变,不知道大家有什么感觉,笔者觉得很方便,同时又兼容之前的功能,是个很不错的创新。不过,微软并不打算把这一很酷的功能提供给广大的开发人员。

    本文提供了一个简单的Address Bar实现,使用.NET 2.0和VS2008. 它是基于一个简单的树型遍历实现的,同时适用于各种级联数据。

    Demo中提供的是一个非常简单的示例,可以浏览文件系统。这里这是展示它是如何工作的。

     

    使用代码

    了解实现最简单的办法就是直接下载源代码,然后打开玩玩看~

    在Design-Time下将Address Bar Control拖入Form,然后再构造器中加入下面一行代码:

    //Initialize the bar with a root node type.
    this.AdBar.InitializeRoot(new FileSystemNode());

    你只需要传入一个根节点,然后根节点就会为control提供信息。FileSystemNode包含Windows系统安装后的第一个逻辑盘信息。 要实现IAddressNode类型,有如下三个重要的方法需要自己实现:

    UpdateNode() - Used to update the node itself for any changes (e.g. in the FileSystemNode it checks for child folder changes and folder name changes)
     
    GetChild() - Searches for a given child node based on a unique ID (A Unique ID being whatever you define it as. In FileSystemNode, we use an absolute path for a folder as the unique ID).
     
    Clone() - Clones a given node as a separate value copy (rather than just by reference).

    总结

    示例很简单,相对来说也是轻量级的实现。如果想用它操作输了FileSystemNode以外的数据,你只需要实现IAddressNode接口,任何级联结构(hierarchical structure)的数据都可以用它来呈现。

    许可证

    本文以及示例代码文件遵循The Code Project Open License(CPOL)

    源码下载

    附件:AddressBarExt2_1.zip

    英文链接:Vista Style Address Bar for .NET 2.0/WinForms

     
  • 相关阅读:
    使用集合组织相关数据
    引用类型传递 ListView展示数据
    关于ArrayList线程安全解决方案
    Java异常错误的面试题及答案
    希尔排序
    Struts2的简单认识
    新闻发布系统
    了解vo pojo javabean dto
    Spring MVC 笔记及简单了解
    jsp的九大内置对象
  • 原文地址:https://www.cnblogs.com/zhangkeyu/p/6663920.html
Copyright © 2011-2022 走看看