Windows 7樣式地址欄(Address Bar)控制項實現

來源:互聯網
上載者:User

標籤:root   fine   開發   one   一行代碼   cin   border   self   iad   

介紹

從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).

Windows 7樣式地址欄(Address Bar)控制項實現

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.