你的位置:首页 > ASP.net教程

[ASP.net教程]C# winform控件之弹出窗口学习积累


1.弹出窗体选择本地文件-OpenFileDialog

OpenFileDialog openFileDialog = new OpenFileDialog();openFileDialog.Title = "窗体左上角标题";//窗体左上角标题openFileDialog.ShowHelp = true;//显示帮助按钮openFileDialog.Filter = "文本文件(.txt)|*.txt|JPG文件(.jpg)|*.jpg|所有文件|*.*"; //过滤文件格式openFileDialog.FilterIndex = 3;//格式索引 从1开始 1:文本文件 2:JPG文件 3:所有文件openFileDialog.InitialDirectory = @"C:\";//第一次打开的默认路径openFileDialog.Multiselect = false;//文件是否能多选//openFileDialog.DefaultExt = ".txt";//设置或获取文件扩展名//选择好文件后点击OK按钮if (openFileDialog.ShowDialog() == DialogResult.OK){  }效果图: