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