C# WinForm 技巧八:界面开发之“WeifenLuo.WinFormsUI.Docking+OutLookBar” 使用

2021-10-02 09:18

阅读:1091

标签:概述  转自 http://www.cnblogs.com/luomingui/archive/2013/09/19/3329763.html    最近几天一直在关注WinFrom方面的文章 有想着提炼一下项目的公共部分,公共部分有分为 界面,类库两方面,今天主要是把界面也先提炼提炼。   WeifenLuo.WinFormsUI.Docking + OutLookBar结合使用的效果图     WeifenLuo.WinFormsUI.Docking修改记录   从http://sourceforge.net/projects/dockpanelsuite上下载源码新建DockContentEx文件并继承WeifenLuo.WinFormsUI.Docking.DockContent在里面加入ContextMenuStrip菜单工具并加入 关闭 全部关闭 除此之外全部关闭 三个菜单。项目结构如下 组件结构图: 源代码如下: /// /// 很多窗体都在Tab中有个右键菜单,右击的里面有关闭,所以最好继承一下DockContent, /// 让其它窗体只要继承这个就有了这个右键菜单 /// public class DockContentEx : DockContent { //在标签上点击右键显示关闭菜单 public DockContentEx( ) { System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip(); // // tsmiClose // System.Windows.Forms.ToolStripMenuItem tsmiClose = new System.Windows.Forms.ToolStripMenuItem(); tsmiClose.Name = "cms"; tsmiClose.Size = new System.Drawing.Size(98, 22); tsmiClose.Text = "关闭"; tsmiClose.Click += new System.EventHandler(this.tsmiClose_Click); // // tsmiALLClose // System.Windows.Forms.ToolStripMenuItem tsmiALLClose = new System.Windows.Forms.ToolStripMenuItem(); tsmiALLClose.Name = "cms"; tsmiALLClose.Size = new System.Drawing.Size(98, 22); tsmiALLClose.Text = "全部关闭"; tsmiALLClose.Click += new System.EventHandler(this.tsmiALLClose_Click); // // tsmiApartFromClose // System.Windows.Forms.ToolStripMenuItem tsmiApartFromClose = new System.Windows.Forms.ToolStripMenuItem(); tsmiApartFromClose.Name = "cms"; tsmiApartFromClose.Size = new System.Drawing.Size(98, 22); tsmiApartFromClose.Text = "除此之外全部关闭"; tsmiApartFromClose.Click += new System.EventHandler(this.tsmiApartFromClose_Click); // // tsmiClose // cms.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { tsmiClose,tsmiApartFromClose,tsmiALLClose}); cms.Name = "tsmiClose"; cms.Size = new System.Drawing.Size(99, 26); this.TabPageContextMenuStrip = cms; } private void tsmiClose_Click(object sender, EventArgs e) { this.Close(); } private void tsmiALLClose_Click(object sender, EventArgs e) { DockContentCollection contents = DockPanel.Contents; int num = 0; while (num


评论


亲,登录后才可以留言!