📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics; //引用命名空间
namespace WinApp9_5通用对话框
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void menuO_Click(object sender, EventArgs e)
{ //对话框中可选的文件类型
opnDlg.Filter="Word文档|*.doc|图像文件|*.jpg;*.bmp;*.gif";
opnDlg.Multiselect=false; // 确保文件只能单选
if (opnDlg.ShowDialog() == DialogResult.OK)
{
txtFileInfo.Text = opnDlg.FileNames[0];
Process.Start(opnDlg.FileNames[0]);
}
}
private void menuX_Click(object sender, EventArgs e)
{
this.Close();
}
private void menuF_Click(object sender, EventArgs e)
{
fntDlg.Font = txtFileInfo.Font;
fntDlg.Color = txtFileInfo.ForeColor;
if (fntDlg.ShowDialog() == DialogResult.OK)
{
txtFileInfo.Font = fntDlg.Font;
txtFileInfo.ForeColor = fntDlg.Color;
}
}
private void fntDlg_Apply(object sender, EventArgs e)
{
txtFileInfo.Font = fntDlg.Font;
txtFileInfo.ForeColor = fntDlg.Color;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -