본문 바로가기

   
Programming/Winform

메세지박스(MessageBox)

반응형

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 WindowsForms01

{

       public partial class Message01 : Form

       {

             public Message01()

             {

                    InitializeComponent();

             }

 

             private void button1_Click(object sender, EventArgs e)

             {

                    //메시지 박스

                    //MessageBox.Show -> 블럭

                    DialogResult result = MessageBox.Show("안녕하세요");

                    MessageBox.Show(result.ToString());

             }

 

 

             private void button2_Click(object sender, EventArgs e)

             {

                    MessageBox.Show("안녕하세요", "인사");

             }

 

             private void button3_Click(object sender, EventArgs e)

             {

                    MessageBox.Show("메시지", "제목", MessageBoxButtons.OKCancel);

                    //MessageBox.Show("메시지", "제목", MessageBoxButtons.YesNoCancel);

                    //MessageBox.Show("메시지", "제목", MessageBoxButtons.RetryCancel);

                    DialogResult result = MessageBox.Show("정말 삭제하시겠습니까?", "파일삭제", MessageBoxButtons.OKCancel);

 

                    if (result == DialogResult.OK)

                           MessageBox.Show("삭제 완료");

                    else

                           MessageBox.Show("취소");

             }

 

             private void button4_Click(object sender, EventArgs e)

             {

 

                    MessageBox.Show("메시지", "제목", MessageBoxButtons.OKCancel);

                    //예 아니오를 반드시 구분 하기 위해서

                    MessageBox.Show("메시지", "제목", MessageBoxButtons.YesNo);

             }

 

             private void button5_Click(object sender, EventArgs e)

             {

                    MessageBox.Show("메시지", "제목", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

             }

 

             private void button6_Click(object sender, EventArgs e)

             {

                    DialogResult result =

                    MessageBox.Show("메시지", "제목", MessageBoxButtons.YesNo, MessageBoxIcon.Question

                    , MessageBoxDefaultButton.Button2);

 

                    MessageBox.Show(result.ToString());

             }

       }

}

 

반응형