保存文件对话框:
SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath); sfd.Filter = "文本文件|*.txt|配置文档|*.ini"; sfd.FileName = "newName"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Do Save }
选择文件对话框:
OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath); ofd.Filter = "文本文件|*.txt|所有文件|*.*"; ofd.FileName = ""; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { }
信息提示弹框:
MessageBox.Show("这是一条测试信息"); if (MessageBox.Show("这是一条测试信息", "Attenation", MessageBoxButtons.YesNo) == DialogResult.Yes){}
文本输入弹框:
using Microsoft.VisualBasic;//引入命名空间 string newPlace = Interaction.InputBox("请输入信息!", "111", "222");
标签:InitialDirectory,ofd,对话框,几种,Forms,sfd,DialogResult,winform From: https://www.cnblogs.com/cfsl/p/17557863.html