103. 파일열기(OpenFileDialog) / 파일저장(SaveFileDialog) / 폴더열기(FolderBrowserDialog) 대화상자
.NET프로그래밍/WinForm 2009. 8. 24. 15:35 |
==> MainForm.cs
// 컨트롤 - 대화상자 - 파일 및 폴더
private void miFileFolder_Click(object sender, EventArgs e)
{
MyWinForms.Controls.FrmFileFolder fff = new MyWinForms.Controls.FrmFileFolder();
fff.MdiParent = this;
fff.Show();
}
==============================================================================================
==> FrmFileFolder.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinForms.Controls
{
public partial class FrmFileFolder : Form
{
public FrmFileFolder()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK) {
MessageBox.Show("선택한 파일 : " + openFileDialog1.FileName);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() != DialogResult.Cancel) {
MessageBox.Show("저장할 파일 : " + saveFileDialog1.FileName);
}
}
private void button3_Click(object sender, EventArgs e)
{
DialogResult dr = folderBrowserDialog1.ShowDialog();
if (dr == DialogResult.OK) {
MessageBox.Show(
"선택한 경로 : " + folderBrowserDialog1.SelectedPath);
}
}
}
}
< 실행결과 >
--> '파일 및 폴더'를 클릭한 후 화면
--> "파일 열기"를 실행한 후 화면
--> "파일 저장"을 실행한 후 화면
--> "폴더 열기"를 실행한 후 화면
'.NET프로그래밍 > WinForm' 카테고리의 다른 글
(테스트) 급여 처리 프로그램 (0) | 2009.08.27 |
---|---|
104. 초간단 노트패드(메모장) 만들기 (0) | 2009.08.24 |
102. 글꼴대화상자(FontDialog) / 색상대화상자(ColorDialog) (0) | 2009.08.24 |
101. DialogResult (부모폼과 자식폼의 값 전달) (0) | 2009.08.24 |
100. 그룹박스(GrouBox) (0) | 2009.08.24 |