轉帖|其它|編輯:郝浩|2010-12-30 14:12:55.000|閱讀 634 次
概述:本文提供了一個簡單的Address Bar實現,使用.NET 2.0和VS2008. 它是基于一個簡單的樹型遍歷實現的,同時適用于各種級聯數據。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
介紹
從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)的數據都可以用它來呈現。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:網絡轉載