zoukankan      html  css  js  c++  java
  • 记事本 对话框

    namespace WindowsFormsApplication6
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                DialogResult dr = colorDialog1.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    this.BackColor = colorDialog1.Color;
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
               DialogResult dr = folderBrowserDialog1.ShowDialog();
               if (dr == DialogResult.OK)
               {
                   MessageBox.Show(folderBrowserDialog1.SelectedPath);
               }
               else
               {
                   MessageBox.Show(folderBrowserDialog1.SelectedPath);
               }
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                fontDialog1.ShowDialog();
                MessageBox.Show(fontDialog1.Font.Size.ToString());
            }
            private string Files;
            private void button4_Click(object sender, EventArgs e)
            {
                DialogResult dr = openFileDialog1.ShowDialog();
                if (DialogResult.OK == dr)
                {
                    string filename = openFileDialog1.FileName;
                    StreamReader sr = new StreamReader(filename);
                    textBox1.Text = sr.ReadToEnd();
                    sr.Close();
    
                    Files = filename;
                }
            }
    
            private void button5_Click(object sender, EventArgs e)
            {
                if (Files == null)
                {
                    saveFileDialog1.Filter = "文本 |*.txt|word|*.doc|excel|*.xls";
                    DialogResult dr = saveFileDialog1.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        string filename = saveFileDialog1.FileName;
    
                        StreamWriter sw = new StreamWriter(filename);
                        sw.Write(textBox1.Text);
                        sw.Close();
                    }
                }
                else
                {
                    StreamWriter sw = new StreamWriter(Files);
                    sw.Write(textBox1.Text);
                    sw.Close();
                }
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button6_Click(object sender, EventArgs e)
            {
                this.Close();
            }
    
            private void button7_Click(object sender, EventArgs e)
            {
                pageSetupDialog1.Document = printDocument1;
                pageSetupDialog1.ShowDialog();
            }
    
            private void button8_Click(object sender, EventArgs e)
            {
                printDialog1.Document = printDocument1;
                DialogResult dr = printDialog1.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    printDocument1.Print();
                }
            }
    
            private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
                System.Drawing.Font f = new System.Drawing.Font("宋体",12);
                e.Graphics.DrawString(textBox1.Text,f,System.Drawing.Brushes.Aqua,5,5);
            }
    
            private void button9_Click(object sender, EventArgs e)
            {
                textBox1.SelectedText = "asd";
            }
    
            private void button10_Click(object sender, EventArgs e)
            {
                FirstForm.Find f = new FirstForm.Find(this.textBox1.SelectedText,this);
                f.Owner = this;
                f.Show();
            }
        }
    }
    

      

  • 相关阅读:
    走进AngularJs(一)angular基本概念的认识与实战
    Android开发:关于WebView
    Mysql 命令大全
    gitHub
    jquery 使用方法
    JS:offsetWidthoffsetleft 等图文解释
    offsetHeight, clientHeight与scrollHeight的区别
    Angular学习-指令入门
    jQuery学习笔记(一):入门
    JACASCRIPT--的奇技技巧的44招
  • 原文地址:https://www.cnblogs.com/ROCKyou/p/4956762.html
Copyright © 2011-2022 走看看