C#:将子Form加入父Form中
实现的功能:已建立了多个子Form界面,在父Form界面左面,点击不同标题的链接文本,父Form界面右面显示不同的子界面内容。
具体如下:
1、加入split拆分器控件
2、在splitControl.panel1中添加不同的链接文本,在splitControl.panel2显示不同界面内容。代码如下:
public partial class Main : Form
{
private Form lastForm = null;
private frmDepartment department = null;
private frmRole role = null; public Main()
{
InitializeComponent();
} private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (department == null)
{
department = new frmDepartment();
}
AddControls(department);
lastForm = department;
} private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (role == null)
{
role = new frmRole();
}
AddControls(role);
lastForm = role;
} private void AddControls(Form form)
{
foreach (Control control in this.splitContainer1.Panel2.Controls)
{
lastForm.Controls.Add(control);
}
//this.splitContainer1.Panel2.Controls.Clear();
foreach (Control control in form.Controls)
{
this.splitContainer1.Panel2.Controls.Add(control);
}
}
C#:将子Form加入父Form中的更多相关文章
- 子窗口访问父页面iframe中的iframe,top打开的子窗口访问父页面中的iframe中的iframe
子窗口访问父页面iframe中的iframe 子窗口访问最顶层页面中的iframe中的iframe top打开的子窗口访问父页面中的iframe中的iframe top打开的子窗口访问最顶层页面中的i ...
- [Swift]扩展String类:实现find()查找子字符串在父字符串中的位置
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- c# winform 子窗体访问父窗体中的方法和变量
今天的工作中突然用到这个了,不过以前没有接触过呢!不过,在有经验的同事的帮助下,这个问题也很快解决了.具体可以分为以下几种方式: 1.在父窗体中构造子窗体对象时,将父窗体传递过去: 如:FrmSub ...
- winform 子窗体调用父窗体中的方法
在父窗体里定义委托 public delegate void inis(string str); 在父窗体中定义要调用的方法 public void inigs(string gs) { textBo ...
- CSS子元素在父元素中水平垂直居中的几种方法
1. 水平居中(margin: auto;)子父元素宽度固定,子元素上设置 margin: auto; 子元素不能设置浮动,否则居中失效. #div1{ width: 300px; height: 3 ...
- 【Vue项目笔记】—— 父子组件之间传递参数和子组件执行父组件中的方法
父组件(MyBlog.vue) <template> <!-- Delete Modal --> <!-- 注意:这里的@deleteBlog中的deleteBlog要和 ...
- 实现 iframe 子页面调用父页面中的js方法
父页面:index.html(使用iframe包含子页面child.html) [xhtml] view plaincopyprint? <html> <head> <s ...
- VB.NET章鱼哥出品—怎样解决MDI子窗口被父窗口中的控件覆盖的问题
近期有个网友问我这个问题,我就上网搜了下,结果非常失望.有几个在CSDN上发的求助帖.看到最后都没有找到明白的答案. 这里笔者在网上找到了API函数SetParent(),并对网上的错误进行了改动,并 ...
- Qt — 子窗体操作父窗体中的方法
父窗体与子窗体各自的代码如下: 1. 父窗体的代码: void FartherWindow::addactions() { SubWindow subwindow(this); // 把父窗体本身t ...
随机推荐
- PostgreSQL 对字段大小写敏感
缘起 iso=> \d+ test; Table "public.test" Column | Type | Modifiers | Storage | Descriptio ...
- ReactiveCocoa的使用方法
http://www.open-open.com/lib/view/open1440060663129.html best praticse https://github.com/ReactiveCo ...
- Python xml
第一部分:读 ######## ## # -*- coding:utf-8 -*- """ * User: not me * Date: 11-11-9 * Time: ...
- Java 类型转换以及Object转成其他类型
Object转int int count=(int)map.get("count") int count=Integer.parseInt((String)map.get(&quo ...
- 当As3遇见Swift(二)
字符串:String 都是用String来表示,都是值类型,在传递过程中都会进行拷贝. 计算字符数量 As3: str.length Swift: countElements(str) 数组:Arra ...
- Leetcode: Number of Islands II && Summary of Union Find
A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand oper ...
- 如何不切换windows登陆用户,更换用户名访问共享文件夹
@echo offnet use * /del /ynet use \\192.168.2.1 /user:wr@echo off 先进行删除所有,然后在进行映射,按照部门来,不同的部门可能需要映射的 ...
- 转:NodeJS、NPM安装配置步骤
1.windows下的NodeJS安装是比较方便的(v0.6.0版本之后,支持windows native),只需要登陆官网(http://nodejs.org/),便可以看到下载页面. 2.下载完 ...
- C++ set容器简单用法
set是关联容器,类似于集合,里面的元素不会重复,而且呈现为有序性 常用操作: using namespace std; set<int>:s;1.元素插入:s.insert()2.中序遍 ...
- 最大密集子图(01分数规划+二分+最小割)POJ3155
题意:给出一副连通图,求出一个子图令g=sigma(E)/sigma(V); h[g]=sigma(E)-g*sigma(V):设G是最优值 则当h[g]>0:g<G h[g]<0, ...