DevExpress12、DocumentManager
DocumentManager控件
你用过Photoshop吗?里面每打开一个照片,就有一个小窗体承载这个照片,你可以在这些小窗体间切换,最小化、最大化、排列窗体,
这些操作都在Photoshop的大框架(MDI主窗体)里,而这些小窗体就是MDI子窗体。
MDI是Multiple Document Interface的缩写,就是多文档界面的意思。它是和单文档SDI相对的。
MDI和SDI在界面上的主要区别如下:MDI允许用户同时打开多个文档,而SDI只能打开一个文档。
MDI子窗体可以通过DocumentManger控件,以 nativemdiview 对象或 tabbedview 对象的形式展现出来;
通过其 ViewCollection属性 添加View视图(子窗体),可以添加TabbedView、WindowsUIView、WidgetView、NativeMdiView四种视图;
通过Run Designer中Main下的Document给视图添加Document文档(显示的面板);
NativeMdiView视图
实现效果如图:
通过代码实现如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraEditors; using DevExpress.XtraBars.Docking2010; using DevExpress.XtraBars.Docking2010.Views.NativeMdi; namespace DXApplication_1 { public partial class DocumentMangerForm : DevExpress.XtraEditors.XtraForm { public DocumentMangerForm() { InitializeComponent(); } private void DocumentMangerForm_Load(object sender, EventArgs e) { Encapsulation_CreateDocumentManager(); for (int i = 0; i < 3; i++) { Encapsulation_AddChild(); } } void Encapsulation_CreateDocumentManager() { DocumentManager documentManager = new DocumentManager(); documentManager.MdiParent = this; // type one documentManager.View = new NativeMdiView(); } int childCount = 0; void Encapsulation_AddChild() { Form childForm = new Form(); childForm.Text = "Child Form " + (++childCount); SimpleButton btn = new SimpleButton(); btn.Text = "Button " + childCount; btn.Parent = childForm; // childForm.MdiParent = this; childForm.Show(); } } }
TabbedView视图
实现效果如图:
代码实现如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraEditors; using DevExpress.XtraBars.Docking2010; using DevExpress.XtraBars.Docking2010.Views.Tabbed; namespace DXApplication_1 { public partial class DocumentMangerForm2 : DevExpress.XtraEditors.XtraForm { public DocumentMangerForm2() { InitializeComponent(); } private void DocumentMangerForm2_Load(object sender, EventArgs e) { Encapsulation_CreateDocumentManager(); for (int i = 0; i < 3; i++) { Encapsulation_AddChild(); } } void Encapsulation_CreateDocumentManager() { DocumentManager documentManager = new DocumentManager(); documentManager.MdiParent = this; // another type documentManager.View = new TabbedView(); } int childCount = 0; void Encapsulation_AddChild() { Form childForm = new Form(); childForm.Text = "Child Form " + (++childCount); SimpleButton btn = new SimpleButton(); btn.Text = "Button " + childCount; btn.Parent = childForm; // childForm.MdiParent = this; childForm.Show(); } } }
posted on 2019-01-21 14:43 springsnow 阅读(2068) 评论(0) 编辑 收藏 举报