轉(zhuǎn)帖|其它|編輯:郝浩|2010-12-30 14:12:55.000|閱讀 634 次
概述:本文提供了一個簡單的Address Bar實現(xiàn),使用.NET 2.0和VS2008. 它是基于一個簡單的樹型遍歷實現(xiàn)的,同時適用于各種級聯(lián)數(shù)據(jù)。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
介紹
從Vista開始,地址欄就有了很大的改變,不知道大家有什么感覺,筆者覺得很方便,同時又兼容之前的功能,是個很不錯的創(chuàng)新。不過,微軟并不打算把這一很酷的功能提供給廣大的開發(fā)人員。
本文提供了一個簡單的Address Bar實現(xiàn),使用.NET 2.0和VS2008. 它是基于一個簡單的樹型遍歷實現(xiàn)的,同時適用于各種級聯(lián)數(shù)據(jù)。
Demo中提供的是一個非常簡單的示例,可以瀏覽文件系統(tǒng)。這里這是展示它是如何工作的。
使用代碼
了解實現(xiàn)最簡單的辦法就是直接下載源代碼,然后打開玩玩看~
在Design-Time下將Address Bar Control拖入Form,然后再構(gòu)造器中加入下面一行代碼:
//Initialize the bar with a root node type.
this.AdBar.InitializeRoot(new FileSystemNode());
你只需要傳入一個根節(jié)點,然后根節(jié)點就會為control提供信息。FileSystemNode包含Windows系統(tǒng)安裝后的第一個邏輯盤信息。要實現(xiàn)IAddressNode類型,有如下三個重要的方法需要自己實現(xiàn):
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).
總結(jié)
示例很簡單,相對來說也是輕量級的實現(xiàn)。如果想用它操作輸了FileSystemNode以外的數(shù)據(jù),你只需要實現(xiàn)IAddressNode接口,任何級聯(lián)結(jié)構(gòu)(hierarchical structure)的數(shù)據(jù)都可以用它來呈現(xiàn)。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:網(wǎng)絡(luò)轉(zhuǎn)載