直接上代码

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();
}

效果图

SandDock 应用示例的更多相关文章

  1. Swift3.0服务端开发(一) 完整示例概述及Perfect环境搭建与配置(服务端+iOS端)

    本篇博客算是一个开头,接下来会持续更新使用Swift3.0开发服务端相关的博客.当然,我们使用目前使用Swift开发服务端较为成熟的框架Perfect来实现.Perfect框架是加拿大一个创业团队开发 ...

  2. .NET跨平台之旅:将示例站点升级至 ASP.NET Core 1.1

    微软今天在 Connect(); // 2016 上发布了 .NET Core 1.1 ,ASP.NET Core 1.1 以及 Entity Framework Core 1.1.紧跟这次发布,我们 ...

  3. 通过Jexus 部署 dotnetcore版本MusicStore 示例程序

    ASPNET Music Store application 是一个展示最新的.NET 平台(包括.NET Core/Mono等)上使用MVC 和Entity Framework的示例程序,本文将展示 ...

  4. WCF学习之旅—第三个示例之四(三十)

           上接WCF学习之旅—第三个示例之一(二十七)               WCF学习之旅—第三个示例之二(二十八)              WCF学习之旅—第三个示例之三(二十九)   ...

  5. JavaScript学习笔记(一)——延迟对象、跨域、模板引擎、弹出层、AJAX示例

    一.AJAX示例 AJAX全称为“Asynchronous JavaScript And XML”(异步JavaScript和XML) 是指一种创建交互式网页应用的开发技术.改善用户体验,实现无刷新效 ...

  6. XAMARIN ANDROID 二维码扫描示例

    现在二维码的应用越来越普及,二维码扫描也成为手机应用程序的必备功能了.本文将基于 Xamarin.Android 平台使用 ZXing.Net.Mobile  做一个简单的 Android 条码扫描示 ...

  7. iOS之ProtocolBuffer搭建和示例demo

    这次搭建iOS的ProtocolBuffer编译器和把*.proto源文件编译成*.pbobjc.h 和 *.pbobjc.m文件时,碰到不少问题! 搭建pb编译器到时没有什么问题,只是在把*.pro ...

  8. Android种使用Notification实现通知管理以及自定义通知栏(Notification示例四)

    示例一:实现通知栏管理 当针对相同类型的事件多次发出通知,作为开发者,应该避免使用全新的通知,这时就应该考虑更新之前通知栏的一些值来达到提醒用户的目的.例如我们手机的短信系统,当不断有新消息传来时,我 ...

  9. oracle常用函数及示例

    学习oracle也有一段时间了,发现oracle中的函数好多,对于做后台的程序猿来说,大把大把的时间还要学习很多其他的新东西,再把这些函数也都记住是不太现实的,所以总结了一下oracle中的一些常用函 ...

随机推荐

  1. Just Have a Change

    If you still do something meaningless or live a purposeless and empty life. Now, it may be time for  ...

  2. 详细记录python的range()函数用法

    使用python的人都知道range()函数很方便,今天再用到他的时候发现了很多以前看到过但是忘记的细节.这里记录一下range(),复习下list的slide,最后分析一个好玩儿的冒泡程序. 这里记 ...

  3. Object窥探

    /* * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETA ...

  4. hdu 5718 Oracle 高精度

    Oracle Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem ...

  5. HDU 2066 一个人的旅行【Dijkstra 】

    题意:给出s个起点,d个终点,问从这些起点到达终点的最短距离 因为有多个起点,所以把这多个起点的值设为0 哎= =改了好久的说= = 是因为在代码里面的t,不知道为什么调用dijkstra()函数之后 ...

  6. 使用C++读写Excel

    1.导入Excel类型库 使用Visual C++的扩展指令#import导入Excel类型库: 1 2 3 4 5 6 7 8 9 10 11 12 #import "C:\\Progra ...

  7. Linux mv 命令的10个实用例子

    当你想要将文件从一个位置移动到另一个地方并且不想复制它,那么mv 命令是完成这个任务的首选.本文中总结了十个Linux mv 命令的实例,希望能给大家带来一些帮助. 初识 mv 命令 mv 命令是一个 ...

  8. SQLServer—系统中的内存配置

    前言: 本文讲述32位和64位系统中的内存配置,在SQLServer 2005/2008中,DBA们往往尝试开启AWE来限制内存.但是,在SQLServer2012以后,这个选项将被弃用,所以不能使用 ...

  9. shell 括号学习

    http://blog.csdn.net/tttyd/article/details/11742241 http://tldp.org/LDP/abs/html/loops1.html

  10. Java类的执行顺序

    在Java中一个类包括:构造块.构造方法.静态块.main方法.普通方法. 通过下面的例子将看出一个类中各种方法的执行顺序: /** * @author zhengbinMac */ public c ...