2017年11月27日 C#MDI窗体创建&记事本打印&记事本查找、自动换行
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窗体创建&记事本打印&记事本查找、自动换行的更多相关文章
- 2017年11月26日 C#流&&窗体对话框
C#流 在顶端加入using System.IO就可以使用流 StreamReder a = new StreamReder();//读取 前面什么都可以 = sr.ReadToEnd();//用法 ...
- 2016年11月27日 星期日 --出埃及记 Exodus 20:18
2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...
- WPS 表格筛选两列相同数据-完美-2017年11月1日更新
应用: 1.选出A列中的数据是否在B列中出现过: 2.筛选出某一批序号在一个表格里面的位置(整批找出) 3.其实还有其他很多应用,难描述出来... ... A列中有几百的名字,本人想帅选出B列中的名字 ...
- Python 爬虫练习(二)爬取补天公益SRC厂商域名URL (2017年11月22日)
介绍下: 补天是国内知名的漏洞响应平台,旨在企业和白帽子共赢. 白帽子在这里提交厂商漏洞,获得库币和荣誉,厂商从这里发布众测.获取漏洞报告和修复建议. 在2017年3月份之前,补天的厂商域名URL是非 ...
- [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 ...
- 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 ...
- 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 ...
- 2016年11月27日--面向对象:多态、类库、委托、is和as运算符、泛型集合
1.虚方法 virtual 重写 override 父类中的方法,在子类中并不适用,那么子类需要自主更改继承的方法或者是属性,那父类中加了virtual关键字的方法才可以被子类重写,子类重写父类的方法 ...
- 2017年11月1日 初学者易上手的SSH-spring 01控制反转(IOC)
这章开始学习SSH中最后的一个框架spring.Spring是一个开放源代码的设计层面框架,他解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用. 首先就来学习一下I ...
随机推荐
- python 中使用 urllib2 伪造 http 报头的2个方法
方法1. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #!/usr/bin/pyth ...
- C - Maximum of Maximums of Minimums(数学)
C - Maximum of Maximums of Minimums You are given an array a1, a2, ..., an consisting of n integers, ...
- java操作AWS S3一些坑记录
1,aws sdk jar版本不一致问题 一开始我在pom.xml中只配置了如下aws-java-sdk-s3 <!-- https://mvnrepository.com/artifact/c ...
- 10分钟教你用VS2017将代码上传到GitHub
前言 关于微软的Visual Studio系列,真可谓是宇宙最强IDE了.不过,像小编这样的菜鸟级别也用不到几个功能.今天给大家介绍一个比较实用的功能吧,把Visual Studio 2017里面写好 ...
- MACD 的数学解释
目录 MACD 的数学解释 MACD 的一般定义 引入延迟算子 Taylor 展开 权重分析 共振? MACD 的数学解释 MACD 的一般定义 \[ \begin{align*} DIF & ...
- 如何判断一个对象实例是不是某个类型,如Cat类型
<script> function cat(){} var b = new cat(); if(b instanceof cat){ console.log("a是cat&quo ...
- PHP错误与异常处理
https://www.cnblogs.com/zyf-zhaoyafei/p/6928149.html 请一定要注意,没有特殊说明:本例 PHP Version < 7 说起PHP异常处理,大 ...
- Q678 有效的括号字符串
给定一个只包含三种字符的字符串:(,) 和 *,写一个函数来检验这个字符串是否为有效字符串.有效字符串具有如下规则: 任何左括号 ( 必须有相应的右括号 ). 任何右括号 ) 必须有相应的左括号 ( ...
- 阿里云redisA迁移redisB迁移
./redis-port restore --input=./xxx.rdb --target=r-2zedc7c8e0557dsf4.redis.rds.aliyuncs.com:6379 --au ...
- java中如何把图片转换成二进制流的代码
在学习期间,把开发过程经常用到的一些代码段做个备份,下边代码内容是关于java中如何把图片转换成二进制流的代码,应该能对各朋友也有用处. public byte[] SetImageToByteArr ...