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 ...
随机推荐
- 2019 JUST Programming Contest J. Grid Beauty
J. Grid Beauty time limit per test 3.0 s memory limit per test 256 MB input standard input output st ...
- Postman使用手册4——API test
一.Pre Request Scripts Postman v0.10+ 版本支持pre-request scripts. prerequest script.png pre-request scri ...
- POJ2279 Mr Young's Picture Permutations
POJ2279 Mr Young's Picture Permutations 描述: 有N个学生合影,站成左对齐的k排,每行分别有N1,N2…NK个人,第一排站最后,第k排站之前.学生身高依次是1… ...
- 如何解决 “invalid resource directory name”, resource “crunch”
Ant and the ADT Plugin for Eclipse are packing the .apk file in a different build chain and temp gen ...
- P01-Python中列表的复制问题
(1)使用=直接赋值 a = [1, 2, 3, [6, 7]] b = a 初始情况: a: [1, 2, 3, [6, 7]] b: [1, 2, 3, [6, 7]] ------------- ...
- C#集合之可观察的集合
如果需要集合中的元素何时删除或添加的信息,可以使用ObservableCollection<T>类.这个类是为WPF定义的,这样UI就可以得知集合的变化.这个类在程序集WindowsBas ...
- Codeforces Round #545 (Div. 2) 题解
题目链接 A. Sushi for Two 题意 在一个 01 序列中找出长为偶数的连续的一段使得它前一半和后一半内部分别相同,而前一半和后一半不同. \(2\le n\le 100\ 000\) 题 ...
- AHB协议
AHB2 支持多个Bus Master,例如有三个Master,有四个slave,但是同时只有一个Mater可以拿到Bus的访问权.所以,总线的使用权就需要Master去申请,也就需要一个仲裁器(Ar ...
- 如何统计Visual Studio Code项目的代码行数
背景 年底到了,公司一年一度做述职报告的时间又到了,每到此时小伙伴们都想方设法的去做一些代码层面的汇总.在此交给大家个小妙招,走过路过不要错过哈,, 解决方案 使用Visual Studio Code ...
- git设置core.autocrlf
背景: 使用虚拟机共享windows文件夹,文件夹中用git clone 一个仓库.在linux下编辑文件,用git status发现几乎所有的文件都为修改状态. 原因: windows下和lin ...