第 1 步 - Document Manager
Document Manager允許您創建一個 Tabbed或 MDI 應用程序 UI,基于相應的視圖(Views),主要的文檔管理器元素是文檔- 能夠包裝所需內容并基于父視圖顯示的對象。
1.啟動 Visual Studio,創建一個新的Windows Forms Application項目,并指定其名稱和位置。
2.在 Visual Studio 工具箱中找到 DocumentManager 組件并將其拖放到您的表單上。
3.通過單擊控件右上角的智能標記按鈕調用 DocumentManager 的智能標記,默認情況下,新添加的 DocumentManager 應用了選項卡式視圖,您可以通過相應的‘Convert to…’鏈接將其更改為另一個可用視圖,默認的 Tabbed View 適用于當前示例,因此保持不變并調用 DocumentManager Designer。
4.切換到設計器中的‘Documents’部分。
在設計器中,您可以添加或刪除文檔并修改它們的屬性。請注意,目前僅啟用了‘Add Document按鈕,文檔可以在文檔創建、文檔激活或表單加載時接收其內容,在此示例中,將使用第三種方法,為此向您的應用程序添加一些用戶控件。
5.在Solution Explorer中右鍵單擊您的項目,然后選擇Add New Item,如下所示
在顯示的對話框中,選擇 User Control并輸入其名稱。
請注意,每個文檔都通過BaseDocument.ControlName和BaseDocument.ControlTypeName屬性與相應的用戶控件相關聯。
6.您現在擁有多個用戶控件,它們代表最終用戶的工作區。現在為每個現有的用戶控件添加一個文檔。打開設計器并再次轉到Documents分。如您所見,Populate按鈕現在可用。單擊此按鈕可為項目中的每個用戶控件添加文檔。
C#
private void tabbedView1_QueryControl(object sender, DevExpress.XtraBars.Docking2010.Views.QueryControlEventArgs e) { if (e.Document.ControlName == "UserControl1") e.Control = new UserControl1(); else e.Control = new UserControl2(); }
VB.NET
Private Sub tabbedView1_QueryControl(sender As Object, e As DevExpress.XtraBars.Docking2010.Views.QueryControlEventArgs) If e.Document.ControlName = "UserControl1" Then e.Control = New UserControl1() Else e.Control = New UserControl2() End If End Sub
8.下圖說明了應用 Office 2013 skin 后的結果。