SandDock 应用示例
2018-06-18 05:18:02来源:未知 阅读 ()
直接上代码
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using TD.SandDock; namespace SalesClient { public partial class frmContainer : Form { public static frmContainer Open; public frmContainer() { InitializeComponent(); frmContainer.Open = this; } Sys.AutoSizeFormClass asc = new SalesClient.Sys.AutoSizeFormClass(); /// <summary> /// 根据传来的窗口变量参数,打开一个窗口到sandDock(单件模式) /// </summary> /// <param name="tempFrm"></param> public void OpenForm_SandDockSingle(Form tempFrm) { if (checkFrm(tempFrm.Name)) { return; } TabbedDocument newWin = new TabbedDocument(); newWin.Name = tempFrm.Name; newWin.Text = tempFrm.Text; newWin.Manager = sandDockManager1; newWin.CloseAction = DockControlCloseAction.Dispose; WindowOpenMethod openMethod = (WindowOpenMethod)(2); tempFrm.Load += new EventHandler(tempFrm_Load); tempFrm.SizeChanged += new EventHandler(tempFrm_SizeChanged); tempFrm.TopLevel = false; tempFrm.Show(); tempFrm.Parent = newWin; tempFrm.Dock = DockStyle.Fill; tempFrm.FormBorderStyle = FormBorderStyle.None; newWin.Open(openMethod); } private void tempFrm_Load(object sender, EventArgs e) { Form frm = sender as Form; asc.Initialize(frm); } private void tempFrm_SizeChanged(object sender, EventArgs e) { Form frm = sender as Form; asc.ReSize(frm); } /// <summary> /// 根据传来的窗口变量参数,打开一个窗口到sandDock(单件模式,关闭以前的) /// </summary> /// <param name="tempFrm"></param> public void OpenForm_SandDockSingleOrClose(Form tempFrm) { checkFrmOrClose(tempFrm.Name); TabbedDocument newWin = new TabbedDocument(); newWin.Name = tempFrm.Name; newWin.Text = tempFrm.Text; //newWin.AutoScroll = true; newWin.Manager = sandDockManager1; newWin.CloseAction = DockControlCloseAction.Dispose; WindowOpenMethod openMethod = (WindowOpenMethod)(2); tempFrm.TopLevel = false; tempFrm.Parent = newWin; //tempFrm.Owner = this; tempFrm.Dock = DockStyle.Fill; //tempFrm.WindowState = FormWindowState.Maximized; tempFrm.FormBorderStyle = FormBorderStyle.None; tempFrm.Show(); newWin.Open(openMethod); } /// <summary> /// 根据传来的窗口变量参数,打开一个窗口到sandDock(非单件模式) /// </summary> /// <param name="tempFrm"></param> public void OpenForm_SandDock(Form tempFrm) { try { TabbedDocument newWin = new TabbedDocument(); newWin.Name = tempFrm.Name; newWin.Text = tempFrm.Text; // newWin.AutoScroll = true; newWin.Manager = sandDockManager1; newWin.CloseAction = DockControlCloseAction.Dispose; WindowOpenMethod openMethod = (WindowOpenMethod)(2); tempFrm.TopLevel = false; tempFrm.Parent = newWin; //tempFrm.Owner = this; tempFrm.Dock = DockStyle.Fill; // tempFrm.Left = (newWin.Width - tempFrm.Width) / 2+newWin.Left; //tempFrm.WindowState = FormWindowState.Maximized; tempFrm.FormBorderStyle = FormBorderStyle.None; tempFrm.Show(); newWin.Open(openMethod); } catch (Exception) { MessageBox.Show("加载窗体(sandDock)出现错误", "窗体加载到sanddock", MessageBoxButtons.OK, MessageBoxIcon.Information); } } /// <summary> /// 窗体单件模式 /// </summary> /// <param name="strFrm"></param> /// <returns></returns> private bool checkFrm(string strFrm) { bool boolRet = false; foreach (TabbedDocument aa in sandDockManager1.Documents) { if (aa is TabbedDocument && ((TabbedDocument)aa).Name == strFrm) { ((TabbedDocument)aa).Activate(); boolRet = true; } } return boolRet; } /// <summary> /// 窗体的单件模式(关闭以前窗体) /// </summary> /// <param name="strFrmName"></param> private void checkFrmOrClose(string strFrmName) { foreach (TabbedDocument aa in sandDockManager1.Documents) { if (aa is TabbedDocument && ((TabbedDocument)aa).Name == strFrmName) { ((TabbedDocument)aa).Close(); } } } } }
在FormLoad 里
private void FormMain_Load(object sender, EventArgs e) { MethodInvoker mi = new MethodInvoker(InvokeMethod); this.BeginInvoke(mi); } private void InvokeMethod() { frmContainer sanddock = new frmContainer(); sanddock.TopLevel = false; sanddock.FormBorderStyle = FormBorderStyle.None; sanddock.Dock = DockStyle.Fill; //sanddock.Width = this.spcMain.Panel2.Width; //sanddock.Height = this.spcMain.Panel2.Height; sanddock.AutoScroll = true; this.spcMain.Panel2.Controls.Clear(); this.spcMain.Panel2.Controls.Add(sanddock); sanddock.Show(); }
效果图
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:Oracle 数据库维护相关
下一篇:表达式树基础
- 如何优雅地停止 Spring Boot 应用? 2020-06-08
- 详解SpringBoot(2.3)应用制作Docker镜像(官方方案) 2020-06-08
- 体验SpringBoot(2.3)应用制作Docker镜像(官方方案) 2020-06-07
- 如何在Spring Boot应用启动之后立刻执行一段逻辑?本文详解 2020-06-05
- 如何在Spring Boot应用启动之后立刻执行一段逻辑 2020-06-02
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash