zoukankan      html  css  js  c++  java
  • 打印文件

          private void button1_Click(object sender, EventArgs e)
            {
                //OpenFileDialog dlg = new OpenFileDialog();  

                OpenFileDialog dlg = new OpenFileDialog();
                if (dlg.ShowDialog() != DialogResult.OK)
                    return; textBox1.Text = dlg.FileName;


                //OpenFileDialog fileDialog1 = new OpenFileDialog();
                //fileDialog1.InitialDirectory = "d:\";//初始目录
                //fileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";//文件的类型
                //fileDialog1.FilterIndex = 1;
                //fileDialog1.RestoreDirectory = true;
                //if (fileDialog1.ShowDialog() == DialogResult.OK)
                //{
                //    textBox1.Text = fileDialog1.FileName;
                //}
                //else
                //{
                //    textBox1.Text = "";
                //}

                //TextFilePrinter p = new TextFilePrinter(tbxFileName.Text); p.View();// 打印预览  p.Print(); // 打印文件
            }

            private void button2_Click(object sender, EventArgs e)
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                //不现实调用程序窗口,但是对于某些应用无效
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                //采用操作系统自动识别的模 式
                p.StartInfo.UseShellExecute = true;
                //要打印的文件路径,可以是WORD,EXCEL,PDF,TXT等等
                p.StartInfo.FileName = textBox1.Text;             // @"d:a.doc";
                //指定执行的动作,是打印,即print,打开是 open
                p.StartInfo.Verb = "print";
                //开始
                p.Start();

              


            }
        }

  • 相关阅读:
    【LeetCode】147. Insertion Sort List
    【LeetCode】64. Minimum Path Sum
    【LeetCode】7. Reverse Integer
    【LeetCode】107. Binary Tree Level Order Traversal II (2 solutions)
    【LeetCode】114. Distinct Subsequences
    【LeetCode】35. Search Insert Position (2 solutions)
    为什么easyui的datagrid里getSelections还有getChecked只能获取一行值呢?
    IE兼容模式下 SCRIPT1028: 缺少标识符、字符串或数字
    修改easyui的easyloader的默认css目录路径
    如何在Visual Studio的查找功能中使用正则表达式?
  • 原文地址:https://www.cnblogs.com/yyzyou/p/3714109.html
Copyright © 2011-2022 走看看