MDI窗体第一个父窗体

把属性里的IsMdiContainer设置为true就可以了

父窗体连接子窗体

//创建一个新的类,用来连接别的窗体,并且别的窗体为唯一窗体

List<Form> F = new List<Form>();
private void opendao(Form f)
{
Form F1 = null;
bool isopen = false;
foreach(Form gf in F)
{
gf.Hide();
if(gf.Name == f.Name)
{
isopen = true;
F1 = gf;
}
} if (isopen)
{
f.Close();
F1.Show();
}
else
{
f.MdiParent = this;
f.WindowState = FormWindowState.Maximized;
f.Parent = panel1;
f.FormBorderStyle = FormBorderStyle.None;
f.Show();
F.Add(f);
} }

第一个按钮的连接或者别的也可以

//连接到第二个窗口

 private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Name = "";
opendao(f2); }

第二个按钮连接或者别的也可以

//连接到第二个窗口   

 private void button2_Click(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.Name = "";
opendao(f3);
}

注:可以多个窗体连接只显示在父窗体里

记事本页面设置

 private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
pageSetupDialog1.Document = printDocument1;
DialogResult dr = pageSetupDialog1.ShowDialog(); if (dr == DialogResult.OK)
{ }
}

记事本打印

//注:第一个代码为绘画,将字符串绘画,重要!

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
string s = textBox1.Text;
Font f = new System.Drawing.Font("微软雅黑", 25.5f);
Brush b = new SolidBrush(Color.Red);
e.Graphics.DrawString(s, f, b, , );
} //打印 private void 打印PToolStripMenuItem_Click(object sender, EventArgs e)
{
printDialog1.Document = printDocument1;
DialogResult dr = printDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
printDocument1.Print();
}
}

记事本打印预览

        private void 打印预览VToolStripMenuItem_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog(); }

记事本自动换行

  private void 自动换行ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (textBox1.WordWrap)
{
//不自动换行
textBox1.WordWrap = false;
textBox1.ScrollBars = ScrollBars.Both;
自动换行ToolStripMenuItem.Checked = false;
}
else
{
//自动换行
textBox1.WordWrap = true;
textBox1.ScrollBars = ScrollBars.Vertical;
自动换行ToolStripMenuItem.Checked = true;
}
}

记事本新窗体查找

//此为第二个窗口的设置
Form1 F1;
public Form2(Form1 f1)
{
InitializeComponent(); F1 = f1;
}
int a = ;
private void button1_Click(object sender, EventArgs e)
{
string s = textBox1.Text; a = F1.textBox1.Text.IndexOf(s, a + );
if (a != -)
{
F1.textBox1.Select(a, s.Length);
F1.textBox1.Focus();
}
else
{
MessageBox.Show("无匹配项!");
}
}
//此为第一个窗口使用
private void 查找ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(this);
f2.Owner = this;
f2.Show(); }

2017年11月27日 C#MDI窗体创建&记事本打印&记事本查找、自动换行的更多相关文章

  1. 2017年11月26日 C#流&&窗体对话框

    C#流 在顶端加入using System.IO就可以使用流 StreamReder a = new StreamReder();//读取 前面什么都可以 = sr.ReadToEnd();//用法 ...

  2. 2016年11月27日 星期日 --出埃及记 Exodus 20:18

    2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...

  3. WPS 表格筛选两列相同数据-完美-2017年11月1日更新

    应用: 1.选出A列中的数据是否在B列中出现过: 2.筛选出某一批序号在一个表格里面的位置(整批找出) 3.其实还有其他很多应用,难描述出来... ... A列中有几百的名字,本人想帅选出B列中的名字 ...

  4. Python 爬虫练习(二)爬取补天公益SRC厂商域名URL (2017年11月22日)

    介绍下: 补天是国内知名的漏洞响应平台,旨在企业和白帽子共赢. 白帽子在这里提交厂商漏洞,获得库币和荣誉,厂商从这里发布众测.获取漏洞报告和修复建议. 在2017年3月份之前,补天的厂商域名URL是非 ...

  5. [svc]linux常用手头命令-md版-2017年11月12日 12:31:56

    相关代码 curl命令-网站如果3次不是200或301则报警 curl -o /dev/null -s -w "%{http_code}" baidu.com -k/--insec ...

  6. Saving James Bond - Easy Version 原创 2017年11月23日 13:07:33

    06-图2 Saving James Bond - Easy Version(25 分) This time let us consider the situation in the movie &q ...

  7. 2017年2月27日Unicorn, US (148) and China (69), followed by the U.K. (10), India (9), Israel (5) and Germany (5).

    Revisiting The Unicorn Club Get to know the newest crowd of billion dollar startups In 2013, when Ai ...

  8. 2016年11月27日--面向对象:多态、类库、委托、is和as运算符、泛型集合

    1.虚方法 virtual 重写 override 父类中的方法,在子类中并不适用,那么子类需要自主更改继承的方法或者是属性,那父类中加了virtual关键字的方法才可以被子类重写,子类重写父类的方法 ...

  9. 2017年11月1日 初学者易上手的SSH-spring 01控制反转(IOC)

    这章开始学习SSH中最后的一个框架spring.Spring是一个开放源代码的设计层面框架,他解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用. 首先就来学习一下I ...

随机推荐

  1. 使用git命令提示“不是内部或外部命令

    问题描述: 打开windows的cmd,在里面打git命令会提示“不是内部或外部命令,也不是可运行的程序” 解决办法: 找到git安装路径中bin的位置,如:D:\Program Files\Git\ ...

  2. javascript显示年月日时间代码显示电脑时间

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. django通过使用jwt模块实现状态保持

    第一步:安装jwt pip install djangorestframework-jwt 第二步:settings/dev的配置文件配置 REST_FRAMEWORK = { # 认证配置 'DEF ...

  4. LINUX主机通过域名访问网络失败

    故障现象: 用telnet IP+端口的方式测试正常,能够访问: 通过telnet域名+端口方式,提示:未知的名称或服务(Name or service not known). 测试百度的网络地址,p ...

  5. Linux下简易进度条的实现

    在生活中,进度条是很常见的,那么,进度条是如何实现的呢? 首先,进度条的动态是利用人眼视觉暂留效果的.实际上是如下过程: 先输出:[=                                  ...

  6. ubuntu14.04部署kickstart

    转自:http://www.mamicode.com/info-detail-1646465.html kickstart用于在内网自动安装系统. 使用pxe安装系统需要安装dhcp,tftp,htt ...

  7. 世界最大BT服务器本周死了三回 海盗湾要凉凉?

    想當初,我是受到BT網站海盜灣的啟發,開發了一個DHT下載網站:http://www.ibmid.com,有一段時間通宵編程,理解此個協議. 海盗湾(The Pirate Bay)是世界上最大的 BT ...

  8. FlutterToast 使用

    参看 FlutterToast 开源库 https://github.com/PonnamKarthik/FlutterToast

  9. 02-oracle字符函数

    字符函数(scott/tiger 登陆) --upper(col name)将字符大写 --lower(col name)将字符小写 --initcap(col name)字符串的首字母大写,其余小写 ...

  10. mvc Area(区域)相关技术

    ASP.NET MVC中,是依靠某些文件夹以及类的固定命名规则去组织model实体层,views视图层和控制层的.如果是大规模的应用程序,经常会由不同功能的模块组成,而每个功能模块都由MVC中的三层所 ...