标签:
设计界面:
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 对话框 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { colorDialog1.ShowDialog(); //显示颜色选择器 panel1.BackColor = colorDialog1.Color; //将选定颜色赋值给panel的背景色 } private void button2_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); //显示文件夹选择器 label1.Text = folderBrowserDialog1.SelectedPath; //获取文件路径 } private void button3_Click(object sender, EventArgs e) { fontDialog1.ShowDialog(); label2.Font = fontDialog1.Font; } private void button4_Click(object sender, EventArgs e) { //设置打开文件类型 openFileDialog1.Filter = "文本文件|*.txt|所有文件|*.*"; //显示文件选择器 DialogResult dr = openFileDialog1.ShowDialog(); //获取文件路径 if (dr == DialogResult.OK) //判断用户是否选择了文件 { label3.Text = openFileDialog1.FileName; } } private void button5_Click(object sender, EventArgs e) { //显示文件选择器 DialogResult dr = saveFileDialog1.ShowDialog(); //获取文件路径 if (dr == DialogResult.OK) //判断用户是否选择了文件 { label4.Text = saveFileDialog1.FileName; } } } }
标签:
原文地址:http://www.cnblogs.com/xiao55/p/5831239.html