c#父窗体设置代码
2009-03-17 14:46
309 查看
C#原代码
最佳答案
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace wdemo6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void 新窗体ToolStripMenuItem_Click(object sender, EventArgs e)
{
Myform mf=new Myform();
//设置父窗体为本窗体
mf.MdiParent = this;
//无模式窗体
mf.Show();
//模式窗体
//mf.ShowDialog();
}
private void 新窗体2ToolStripMenuItem_Click(object sender, EventArgs e)
{
Myform mf = new Myform();
Form2 f2 = new Form2();
f2.Show();
//设置父窗体为新产生的f2f
mf.MdiParent = f2;
mf.Show();
}
//子窗体4种排列方式
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);
}
private void 选中窗体ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form=this.ActiveMdiChild;
if (form != null)
{
RichTextBox rtx = (RichTextBox)form.ActiveControl;
rtx.Text = "这是当前选中窗体.";
}
}
private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form = this.ActiveMdiChild;
if (form != null) {
RichTextBox rtx = (RichTextBox)form.ActiveControl;
Clipboard.SetDataObject(rtx.SelectedText);
}
else
{
MessageBox.Show("目前并未选中窗体");
}
}
private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form = this.ActiveMdiChild;
if (form != null)
{
RichTextBox rtx = (RichTextBox)form.ActiveControl;
Clipboard.SetDataObject(rtx.Text);
}
else
{
MessageBox.Show("目前并未选中窗体");
}
}
private void 全部复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form = this.ActiveMdiChild;
if (form != null)
{
RichTextBox rtx = (RichTextBox)form.ActiveControl;
//Clipboard.GetDataObject().GetData(DataFormats.Text);
rtx.Text = Clipboard.GetText();
//Clipboard.SetDataObject(rtx.Text);
}
else
{
MessageBox.Show("目前并未选中窗体");
}
}
private void 选项卡窗体ToolStripMenuItem_Click(object sender, EventArgs e)
{
new Form3().Show();
}
}
}
**********************form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace wdemo6
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
}
}
最佳答案
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace wdemo6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void 新窗体ToolStripMenuItem_Click(object sender, EventArgs e)
{
Myform mf=new Myform();
//设置父窗体为本窗体
mf.MdiParent = this;
//无模式窗体
mf.Show();
//模式窗体
//mf.ShowDialog();
}
private void 新窗体2ToolStripMenuItem_Click(object sender, EventArgs e)
{
Myform mf = new Myform();
Form2 f2 = new Form2();
f2.Show();
//设置父窗体为新产生的f2f
mf.MdiParent = f2;
mf.Show();
}
//子窗体4种排列方式
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);
}
private void 选中窗体ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form=this.ActiveMdiChild;
if (form != null)
{
RichTextBox rtx = (RichTextBox)form.ActiveControl;
rtx.Text = "这是当前选中窗体.";
}
}
private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form = this.ActiveMdiChild;
if (form != null) {
RichTextBox rtx = (RichTextBox)form.ActiveControl;
Clipboard.SetDataObject(rtx.SelectedText);
}
else
{
MessageBox.Show("目前并未选中窗体");
}
}
private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form = this.ActiveMdiChild;
if (form != null)
{
RichTextBox rtx = (RichTextBox)form.ActiveControl;
Clipboard.SetDataObject(rtx.Text);
}
else
{
MessageBox.Show("目前并未选中窗体");
}
}
private void 全部复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form form = this.ActiveMdiChild;
if (form != null)
{
RichTextBox rtx = (RichTextBox)form.ActiveControl;
//Clipboard.GetDataObject().GetData(DataFormats.Text);
rtx.Text = Clipboard.GetText();
//Clipboard.SetDataObject(rtx.Text);
}
else
{
MessageBox.Show("目前并未选中窗体");
}
}
private void 选项卡窗体ToolStripMenuItem_Click(object sender, EventArgs e)
{
new Form3().Show();
}
}
}
**********************form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace wdemo6
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
}
}
相关文章推荐
- C#五行代码设置透明窗体效果
- C#代码设置窗体和Panel的位置大小
- 设置窗体透明C#代码
- 【C#】Windows Mobile 通过代码设置GPRS连接,设置网络与接入点
- VS 2008 C#代码调试进C++代码设置/远程调试
- 代码设置窗体的弹出模式
- c# WINDOW窗体应用常用代码
- C# WinForm 如何设置窗体背景为渐变色
- 几行代码帮您实现Win7窗体的打开效果(C#)
- C#:C#与libLAS的简单操作(VS2010窗体+代码)
- c# 控件,线程间操作(设置主窗体控件数据)
- 在代码中对窗体设置透明度灰度的方法
- PowerDesigner生成C#代码模板设置
- 转载:C# 设置文件夹权限(代码简单)
- C#实现开机自动启动设置代码分享
- Style样式的四种使用(包括用C#代码动态加载资源文件并设置样式)
- 黄聪:如何判断VS开发C#是否为设计模式,以免编译之前操作窗体设计器代码自动运行
- c#窗体支持多个文件拖放的代码实现
- C#.NET 可以为不同的客户定制不同的登录窗体的设计思路参考【功能代码组件化,可以灵活选配】
- c# 弹出窗体选择文件代码