P92认识对话框

P92认识对话框

 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 P92认识对话框
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//选择文件
private void button1_Click(object sender, EventArgs e)
{
//设置对话框标题
this.openFileDialog1.Title = "选择数据文件";
//按照扩展名过滤文件
this.openFileDialog1.Filter = "Excle文件|*.xls;*.xlsx|所有文件|*.*";
//是否支持多选
this.openFileDialog1.Multiselect = true;
if (this.openFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
this.textBox1.Text = this.openFileDialog1.FileName;
}
}
//选择文件夹
private void button2_Click(object sender, EventArgs e)
{
//设置对话框的描述
this.folderBrowserDialog1.Description = "请选择一个文件夹";
//设置对话框的初始目录
this.folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop;
//是否选择新建文件夹
this.folderBrowserDialog1.ShowNewFolderButton = true;
if (folderBrowserDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
this.textBox2.Text = folderBrowserDialog1.SelectedPath;
}
}
//保存文件
private void button3_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "保存到处文件";
sfd.InitialDirectory = @"\d:";
sfd.FileName = "哈哈哈.txt";
sfd.Filter = "记事本|*.txt|所有问价|*.*";
if (sfd.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
this.textBox3.Text = sfd.FileName;
}
} private void button4_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
this.textBox4.Text = cd.Color.ToString();
}
} private void button5_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
if (fd.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
this.textBox5.Text = fd.Font.ToString();
}
}
}
}
上一篇:学习android学习必备的java基础知识--四大内部类


下一篇:利用SQL语句查找某数据库中所有存储过程包含的内容(转)