WinForm窗体嵌入

一、在winform窗体上添加两个控件

1、容器>Panel

2、添加 SideBar.dll (下载链接:http://pan.baidu.com/s/1o6qhf9w

(1)将SideBar.dll放到SideBar控件\bin\Debug下

(2)拖动SideBar.dll到工具箱>常规 选项卡内

3、实现效果如下图

注:窗体左边是SideBar控件,右边是Panel容器

二、后台代码

(1)sideBar1_Load事件

sideBar1.AddGroup("小组名");

sideBar1.Groups[0].Items.Add("组员名",1);  注:1是我随意写的,不需要用到这个

(2)sideBar1_ItemDoubleClick事件

注:点击小组成员的名字,Panel中显示form2窗体的内容

if( e.Item.Text == "晓白")

{

//重绘Panel

panel1.Controls.Clear();

Form2 f2 = new Form2();

//隐藏子窗体边框(去除最小花,最大化,关闭等按钮)

f2.FormBorderStyle = FormBorderStyle.None;

//指示子窗体非顶级窗体(注:这个很重要,如果子窗体是顶级窗体,是没有办法嵌入到父窗体中的)

f2.TopLevel = false;

// 将子窗体载入panel

this.panel1.Controls.Add(f2);                  f2.Show();

}

三、效果图

四、结束附上源码:http://pan.baidu.com/s/1i3sZhbR

时间: 2024-12-04 23:09:18

WinForm窗体嵌入的相关文章

winForm窗体嵌入U3d

最近新做一项目,需要winForm框架嵌入u3d,并且实现交互.从网上搜了各种资料,总结了三种方法: 1.直接打开exe程序 System.Diagnostics.Process.Start(@"D:\Demo\Demo1020.exe"); 缺点:u3d不嵌入到窗体 而是单独的打开. 优点:算是优点吧,画面还是比较流畅的 2.用网上封装好的方法嵌入窗体 可以看这里的实现 代码就不自己贴了 嫌麻烦 http://blog.csdn.net/lisenyang/article/detai

C#将exe运行程序嵌入到自己的winform窗体中

以下例子是将Word打开,然后将它嵌入到winform窗体中,效果如下图:C将exe运行程序嵌入到自己的winform窗体中 - kingmax_res - iSport注意:该方法只适用于com的exe(如word,Excel之类),.net的编的exe就不能用这用方法嵌入到窗体中. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using Syst

winform窗体中查找控件

private RichTextBox FindControl()        { RichTextBox ret = null;            try            {                Control[] controls = Application.OpenForms["MainForm"].Controls.Find("txtContent", false);                if (controls != nul

c#Winform窗体 自动生成EXCEL并可以插入数据

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data; using System.Windows.Forms; using System.Data.OleDb;using System.IO;using System.Drawing;using System.Linq;using System.Text; namespace EPAS.f06PreData//自己命名

C#使用事件方式Winform窗体之间传值

[摘自:http://www.cnblogs.com/codeToUp/p/5371062.html] 工程的源代码地址:https://github.com/yes-or-no/WinFormTransValueDemoByDelOrEvent.git C#winform窗体间传值,三种方法示例,注释详细.使用方法:使用vs2013打开编译运行即可: 工程中总共介绍了三种方法:###方法1:通过保存对象的引用调用其方法实现对子窗体的控制:###方法2:通过委托,在子窗体显示之前,为委托赋值,关

WPF加载Winform窗体时 报错:子控件不能为顶级窗体

一.wpf项目中引用WindowsFormsIntegration和System.Windows.Forms 二.Form1.Designer.cs 的 partial class Form1 设置为:public partial class Form1 三.代码如下: XXXX.Form1 Zhuwindow = new XXXX.Form1(); Zhuwindow.TopLevel = false; Zhuwindow.FormBorderStyle = System.Windows.Fo

.NET vs2010中使用IrisSkin2.dll轻松实现winForm窗体换肤功能

.NET vs2010中使用IrisSkin2.dll轻松实现winForm窗体换肤功能 转载▼ 大家好,从事c-s开发的C#程序员经常为winForm的界面设计苦恼,笔者曾经也深受“美工神话”的危害,如今提到美工,界面布局设计就开始蛋疼…. 所幸的是,笔者无意间接触到了一些比较可爱的第三方控件,可以为我们程序员省掉很多美工上面的麻烦…在陆续的博客中我会为大家介绍,今天我们的主题是:IrisSkin2.dll IrisSkin2.dll是一款很不错的免费皮肤控件,利用它可以轻松的实现winFor

小例子(二)、winform窗体间的关系

写一个关于winform窗体间的关系 1.登陆,思路:登陆后隐藏登陆窗体,关闭Form2时结束整个应用程序. 1 //登陆窗体 2 private void button2_Click(object sender, EventArgs e) 3 { 4 Form2 fr = new Form2(); 5 this.Visible = false;//隐藏窗体 6 fr.Show(); 7 } 1 //注册一个关闭时结束程序的事件,FormClosing 2 private void Form2_

winform窗体跟随窗体

Form2 frm2 = new Form2(); private void MoveProc() { frm2.StartPosition = FormStartPosition.CenterParent; frm2.Left = this.Left + panel1.Left; frm2.Top = this.Top + panel1.Top; } public Form1() { InitializeComponent(); MoveProc(); this.AddOwnedForm(fr