블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
반응형

Category

Recent Post

Recent Comment

Archive

2009. 8. 30. 16:30 .Net Project/.Net C#
반응형
 폼 ?
그래픽 환경에서 화면을 구성하고 아용자가 통신하는 가장 기본적은 부품이 바로 윈도우

 WinMainForm 다음과 같이 컴트롤 각각 연습하기



공용컨트롤.CS 

            //모달리스 폼 : 독립적인 하나의 폼
           //각각의 폼으로 연결할수 있도록 이벤트 핸들러 작성
            MyWinFormsStudy.Controls.FrmButton fb =
                   new MyWinFormsStudy.Controls.FrmButton();

            //MDI 컨테이너를 현재 폼(메인)으로 설정
            fb.MdiParent = this;  // 속성 지정 안해주면 MDI폼 안이 아닌 밖에 나타난다.
            //fb에게 mdi부모에게 주겠다  = 메인인 내가

            fb.Show();   




 버튼레이블 렉스트박스
  StringBuilder sb = new StringBuilder();

            sb.Append("싱글라인 : " + txtSingle.Text + "\r\n");
            sb.AppendFormat("멀티라인 : " + txtMulth + "\r\n");          //같은형태1
            sb.AppendLine(string.Format("패스워드 : {0}", txtPwd.Text)); //같은형태1
            sb.AppendLine("마스크 : " + txtMask.Text);
            sb.AppendFormat("리치 : {0}", txtRich.Text); //AppendLined는 애러 왜!?

            MessageBox.Show(sb.ToString());

            //초기값...
            txtSingle.Text = "";
            txtMulth.Text = "";
            txtPwd.Text = "";
            txtMask.Text = "";
            txtRich.Text = "";




namespace MyWinFormsStudy.Controls
{
    public partial class FrmCheckBoxRadioButton : Form
    {
        public FrmCheckBoxRadioButton()
        {
            InitializeComponent();
        }
        private void FrmCheckBoxRadioButton_Load(object sender, EventArgs e)
        {
            //optWomen.Checked = true; //동적으로 체크
        }

        private void btnok_Click(object sender, EventArgs e)
        {
            string msg = "";
            //관심사항
            if (this.chkCsharp.Checked) //msg에 값을 넣는 첫번째 방법
            {
                msg += this.chkCsharp.Text + "\r\n";               
            }

            if (this.chkAsp.Checked == true) //msg에 값을 넣는 두번째 방법
            {
                msg += this.chkAsp.Text + "\r\n";               
            }

            if (this.chkSil.Checked) { //msg에 값을 넣는 세번째 방법
                //Empty
            }
            else {
                msg += this.chkSil.Text + "\r\n";
            }//첫번재 방법 추천
           
            //성별
            if (this.optMan.Checked)
            {
            //한줄 띄고 라이오 텍스트 붙이고 다시 한줄 띄우기
            msg += string.Format("{0} {1} {0}" , "\r\n", optMan.Text);   
            }
            if (this.optWomen.Checked) 
            //한줄 띄고 라이오 텍스트 붙이고 다시 한줄 띄우기
             {
             msg += string.Format("{0} {1} {0}", "\r\n", optWomen.Text);
             }
             this.txtResult.Text = msg;
        }
    }
}
 



 FrmCombo ListBox.Cs
 private void FrmComboListBox_Load(object sender, EventArgs e)
        {
            //동적으로 아이콘의 종류를 리스트박스에 초기화
            lstIconBox.Items.Add(MessageBoxIcon.Error.ToString());
            lstIconBox.Items.Add(MessageBoxIcon.Information.ToString());
            lstIconBox.Items.Add(MessageBoxIcon.Stop.ToString());
            lstIconBox.Items.Add(MessageBoxIcon.Question.ToString());
            lstIconBox.Items.Add(MessageBoxIcon.Warning.ToString());
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cboBox.SelectedIndex != -1 && lstIconBox.SelectedIndex != -1)
            {
                //선택되지 않으면 -1값을 반환한다. 예외처리 해줌
                string btn = cboBox.Items[cboBox.SelectedIndex].ToString();     
                string icon = lstIconBox.Items[lstIconBox.SelectedIndex].ToString();

                //Process
                MessageBox.Show(string.Format("버튼 : {0}, 아이콘 : {1}", btn, icon));
            }
            else
                {
                DialogResult result = MessageBox.Show
                ("콤보박스와 리스트 박스를 선택해주세요.","제목",MessageBoxButtons.OKCancel);
               
                //DialogResult 쓰게 되면 확인과 취소에 따른 결과값을 간단하게 출력 할 수 있다.
                if (result == DialogResult.OK)
                {
                    txtRead.Text = "확인 클릭";
                }
                else if (result == DialogResult.Cancel)
                {
                    txtRead.Text = "취소 클릭";
                }
            }
        }




 Frm 컨테이너 - > 그룹박스. CS



 Frm FontDialog.Cs

        private void btnFont_Click(object sender, EventArgs e)
        {
            //폰트창을 열고
            DialogResult dr = this.fdFont.ShowDialog();
            //확인버튼 누르면, 변경
            if (dr == DialogResult.OK)
            {
                txtFont.Font = fdFont.Font;
            }           
        }
        private void btnColor_Click(object sender, EventArgs e)
        {
            //색상창 열고,
            if (fdColor.ShowDialog() != DialogResult.Cancel)
            {
                txtFont.ForeColor = fdColor.Color; //글꼴색 변경
            }
        }


 Frm FileDialog.CS
         //아래 3개 모두 다 같은 뜻
        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 Project > .Net C#' 카테고리의 다른 글

106장 Form Windows Explorer  (0) 2009.08.30
105장 Form Windows Class  (0) 2009.08.30
2장 정보보안의 세계  (0) 2009.08.28
1장 정보보호개론  (0) 2009.08.28
C# 기초문법 정리(Test)  (0) 2009.08.27
posted by Magic_kit