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. php-fpm 操作命令

    以下内容转自 https://www.cnblogs.com/alibai/p/4070076.html 和 https://blog.csdn.net/wzx19840423/article/det ...

  2. [agc004e]Salvage Robots dp

    Description 蛤蟆国的领土我们可以抽象为H*W的笼子,在这片蛤土上,有若干个机器人和一个出口,其余都是空地,每次蛤蟆会要求让所有的机器人向某个方向移动一步,当机器人移动到出口时会被蛤蟆活摘出 ...

  3. CentOS 下设置 SELinux 安全上下文

    作用: chcon 命令用来改变 SELinux 文件属性即修改文件的安全上下文 用法: chcon [ 选项 ] CONTEXT 文件 选项: -R:递归改变文件和目录的上下文. --referen ...

  4. badboy使用手册

    使用badboy录制脚本 3.1: 页面功能分析: 1. 界面视图,模拟浏览器,能够进行操作 2. 需要录制脚本的URL 3. 点击运行URL 4. Summary:运行的各指标,响应时间,成功事物等 ...

  5. df -h 卡死 如何解决

    df -h 卡死的情况,那是因为无法统计挂载的目录的大小 一般是因为还挂载了一些外部的目录,如nfs的目录 可以用mount | column -t 命令查看哪些目录 然后umount这些目录, 一般 ...

  6. 原生js 实现旋转木马

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

  7. 如何实现java的四则运算

    很多语言底层对四则运算都有内部封装, 我们还是要重复造下轮子,不为别的, 就是为了面试可以多装一分 b, 假设你已经了解了什么是二进制, 什么是异或, 什么是移位运算, 什么是与, 这些不懂就别硬上( ...

  8. StringBuffer类和String类的区别

    StringBuffer是使用缓冲区的,本身也是操作字符串的,但与String类不同,String类的内容一旦声明后是不可改变的,改变的只是其内存的指向,而StringBuffer类的对象内容是可以改 ...

  9. PHP输出毫秒时间戳

    代码: <?php list($msec, $sec) = explode(' ', microtime()); $msectime = (float)sprintf('%.0f', (floa ...

  10. request.upload.addEventListener in not a function。

    本人在使用vue开发一套后台系统时,碰到了一个上传文件的需求,因为平时做的上传是使用ajax的方式来进行上传. 现在是使用axios来进行上传,方式没有什么改变: npm i  axios  直接上 ...