winform父窗体与子窗体设置
小白一个,很久没弄winform窗体,很多东西都忘了。现在想实现程序运行时父窗体和子窗体同时加载,但是子窗体置顶。要求用C#写有完整代码...
小白一个,很久没弄winform窗体,很多东西都忘了。现在想实现程序运行时父窗体和子窗体同时加载,但是子窗体置顶。
要求用C#写 有完整代码 展开
要求用C#写 有完整代码 展开
3个回答
展开全部
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;
namespace Demo1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.MdiParent = this;
f.Show();
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void 全部最小化ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach(Form2 f in this.MdiChildren ){
f.WindowState = FormWindowState.Minimized;
}
}
private void 全部最大化ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form2 f in this.MdiChildren)
{
f.WindowState = FormWindowState.Maximized;
}
}
private void 全部关闭ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form2 f in this.MdiChildren)
{
f.Close();
}
}
private void 水平平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileHorizontal);
}
private void 垂直平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileVertical);
}
private void 层叠ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.Cascade);
}
private void 图标显示ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.ArrangeIcons);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Demo1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.MdiParent = this;
f.Show();
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void 全部最小化ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach(Form2 f in this.MdiChildren ){
f.WindowState = FormWindowState.Minimized;
}
}
private void 全部最大化ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form2 f in this.MdiChildren)
{
f.WindowState = FormWindowState.Maximized;
}
}
private void 全部关闭ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form2 f in this.MdiChildren)
{
f.Close();
}
}
private void 水平平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileHorizontal);
}
private void 垂直平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileVertical);
}
private void 层叠ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.Cascade);
}
private void 图标显示ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.ArrangeIcons);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询