浏览文件按钮
private void btnSelect2_Click(object sender, EventArgs e){string path = GetPath();if (!string.IsNullOrEmpty(path)){tbText2.Text = path;}}private string GetPath(){OpenFileDialog fileDialog = new OpenFileDialog();fileDialog.Title = "選擇文件";fileDialog.Filter = "文本文件(*.txt)|*.txt|數據文件(*.dat)|*.dat|所有文件(*.*)|*.*";fileDialog.FilterIndex = 1;fileDialog.RestoreDirectory = true;if (fileDialog.ShowDialog() == DialogResult.OK){return fileDialog.FileName;}return string.Empty;}
轉載于:https://www.cnblogs.com/zhuawang/archive/2012/07/02/2573184.html
總結
- 上一篇: VS2008调试总结
- 下一篇: 分享一个不错的表格样式