C#

018_MessageBox

iwannabebackendexpert 2022. 3. 30. 00:55

이와 같은 메시지 박스를 출력해보자

private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox.Show("가장 간단한 메시지 박스 입니다.");
            MessageBox.Show("타이틀이 있는 메시지 박스 입니다.", "title");
            DialogResult result1 = MessageBox.Show("두개의 버튼이 있는 메시지 박스입니다.", "Question",
                MessageBoxButtons.YesNo); //두개의 버튼에서 나온 값을 result1에 저장
            DialogResult result2 = MessageBox.Show(
                "세개의 버튼이 있는 메시지 박스입니다.",
                "Question",
                MessageBoxButtons.YesNoCancel,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button3);
            MessageBox.Show("느낌표와 알람", "타이틀",
                MessageBoxButtons.OK,
                MessageBoxIcon.Hand);
            MessageBox.Show(result1.ToString() + " " + result2.ToString());
        
           
                
        }

1. 기본적으로 메시지박스는 MessageBox.Show("   ~   ") 로 출력함.

2. 메시지박스 상단의 타이틀은 MessageBox.Show("   ~   ","  !  ")로 출력함.

3. DialogResult result1,2는 MessageBoxButtons.YesNo & MessageBoxButtons.YesNoCancel의 값을 입력받음.

4. MessageBoxIcon. (  ) 으로 아이콘을 메시지 박스에 출력할 수 있음.

5. MessageBoxDefaultButton.Button -number- 로 디폴트로 버튼이 눌려져있게 정해둘수있음.

6. MessageBoxIcon.Hand 로 아이콘과 경고알람을 출력.

7. 3번에서 입력받은 result1,2를 ToStiring()으로 변환해서 Show()로 출력.

 

 

 

 

 

 

 

 

 

 

 

'C#' 카테고리의 다른 글

020_Labels  (0) 2022.03.30
019_BasicControl  (0) 2022.03.30
017_Forms  (0) 2022.03.30
016_HelloWorld!(Forms)  (0) 2022.03.29
015_Hanoi_tower  (0) 2022.03.16