본문 바로가기
Revit/C# 기초

C# 간단한 WinForm 프로그램

by Crony 2014. 12. 23.

Windows Forms 응용 프로그램 템플릿을 이용한 프로그램

도구 상자의 Label, Button, TextBox, ListBox등을 이용하여 입력한 값을 텍스트 파일로 출력

아래 코드는 저장버턴을 클릭시 실행하는 C#코드 입니다.



// ──────────────────────────────
//          02 C# 간단한 WinForm 프로그램
// ──────────────────────────────
        private void btnSave_Click(object sender, EventArgs e)
        {
            string mf = radioM.Checked ? "남" : "여";
            string data = txtName.Text + ", " + cboRegion.SelectedItem + ", " + dtDOB.Value + ", " + mf;

            StreamWriter Wr = new StreamWriter(@"H:\Temp\Test.txt", true);
            Wr.WriteLine(data);
            Wr.Close();

            txtName.Text = "";
            cboRegion.SelectedIndex = -1;
            dtDOB.Value = DateTime.Now;
        }

'Revit > C# 기초' 카테고리의 다른 글

C# 배열 / 문자열  (0) 2014.12.23
C# 반복문  (0) 2014.12.23
C# 조건문  (0) 2014.12.23
C# 변수/상수  (0) 2014.12.23
C# 시작하기 - 콘솔 프로그램  (0) 2014.12.23