記事本 對話方塊

來源:互聯網
上載者:User

標籤:

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

  

記事本 對話方塊

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.