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

    介绍

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

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

    abe.png

    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



    本文是由葡萄城技术开发团队发布,转载请注明出处:葡萄城官网


  • 相关阅读:
    内容绘制到Bitmap上不成功警示
    一些c++面试题目
    Windows Socket 主要API功能
    面试问题(一)
    函数指针与指针函数
    机器学习和数据挖掘的网站
    vs2010打开vs2008程序出现错误
    MATLAB将矩阵使用.txt文件格式保存
    指针实现值交换
    堆与栈的区别
  • 原文地址:https://www.cnblogs.com/powertoolsteam/p/1917814.html
Copyright © 2011-2022 走看看