zoukankan      html  css  js  c++  java
  • 2017-5-3 打印控件、MDI 窗体容器

    打印控件:
    要打印,第一步先要想到制作打印对象

    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();
                }
            }
        }
    }

  • 相关阅读:
    IIS Express 配置缓存位置
    Docker Demo on Docker
    前端的哪些坑
    如何在container中编译dotnet的eShopOnContainers
    JQuery 常用的那些东西
    jQuery选择器大全
    Js 跨域CORS报错 Response for preflight has invalid HTTP status code 405
    WPF 通过透明度遮罩和变换制作倒影效果
    Ons 让人欲哭无泪问题,官方介绍不详
    如何转换任何配置文件 文件中的内容
  • 原文地址:https://www.cnblogs.com/zhengqian/p/6802650.html
Copyright © 2011-2022 走看看