打印控件:
要打印,第一步先要想到制作打印对象
PrintDocument - 默认事件
Font f = new Font("黑体",20);
Brush b = new SolidBrush(Color.Red);
e.Graphics.DrawString(textBox1.Text, f, b, 20, 50);
通过对于事件数据的绘制来制作要打印的内容
--------------------------------------------------------
MDI 窗体容器
IsMdiContainer----------------确定该窗体是否是MDI容器
MenuStrip-------------------往MDI容器中放置的菜单
企业仓库,销售,财务三个模块的制作(用到MDI容器和唯一窗体):
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication5 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } List<Form> formlist = new List<Form>(); private void 仓库模块ToolStripMenuItem_Click(object sender, EventArgs e) { bool has = false; Form2 f2 = new Form2(); foreach(Form f in formlist) { if(f is Form2) { has = true; f2 = f as Form2; } } if (has == false) { f2.MdiParent = this; f2.WindowState = FormWindowState.Maximized; f2.Parent = panel1; f2.Show(); formlist.Add(f2); } else { foreach (Form f in formlist) { f.Hide(); } f2.Show(); } } private void 销售模块ToolStripMenuItem_Click(object sender, EventArgs e) { bool has = false; Form3 f3 = new Form3(); foreach (Form f in formlist) { if (f is Form3) { has = true; f3 = f as Form3; } } if (has == false) { f3.MdiParent = this; f3.WindowState = FormWindowState.Maximized; f3.Parent = panel1; f3.Show(); formlist.Add(f3); } else { foreach (Form f in formlist) { f.Hide(); } f3.Show(); } } private void 财务模块ToolStripMenuItem_Click(object sender, EventArgs e) { bool has = false; Form4 f4 = new Form4(); foreach (Form f in formlist) { if (f is Form4) { has = true; f4= f as Form4; } } if (has == false) { f4.MdiParent = this; f4.WindowState = FormWindowState.Maximized; f4.Parent = panel1; f4.Show(); formlist.Add(f4); } else { foreach (Form f in formlist) { f.Hide(); } f4.Show(); } } } }