MessageBoxButtons 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
MessageBox표시할 단추를 정의하는 상수입니다.
public enum class MessageBoxButtons
public enum MessageBoxButtons
type MessageBoxButtons =
Public Enum MessageBoxButtons
- 상속
필드
| Name | 값 | Description |
|---|---|---|
| OK | 0 | 메시지 상자에는 확인 단추가 포함되어 있습니다. |
| OKCancel | 1 | 메시지 상자에는 확인 및 취소 단추가 포함되어 있습니다. |
| AbortRetryIgnore | 2 | 메시지 상자에는 중단, 다시 시도 및 무시 단추가 포함됩니다. |
| YesNoCancel | 3 | 메시지 상자에는 예, 아니요 및 취소 단추가 포함되어 있습니다. |
| YesNo | 4 | 메시지 상자에는 예 및 아니요 단추가 포함되어 있습니다. |
| RetryCancel | 5 | 메시지 상자에는 다시 시도 및 취소 단추가 포함되어 있습니다. |
예제
다음 코드 예제에서는 사용자가 폼을 닫지 못하도록 하는 기회를 제공 하는 방법을 보여 MessageBox 줍니다. 이 예제에서는 폼의 이벤트에서 메서드를 FormClosing 호출해야 합니다.
private:
void Form1_FormClosing(Object^ sender, FormClosingEventArgs^ e)
{
// If the no button was pressed ...
if ((MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == DialogResult::No))
{
// cancel the closure of the form.
e->Cancel = true;
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
const string message =
"Are you sure that you would like to close the form?";
const string caption = "Form Closing";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
// If the no button was pressed ...
if (result == DialogResult.No)
{
// cancel the closure of the form.
e.Cancel = true;
}
}
Private Sub Form1_FormClosing( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles MyBase.FormClosing
Dim message As String = _
"Are you sure that you would like to close the form?"
Dim caption As String = "Form Closing"
Dim result = MessageBox.Show(message, caption, _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question)
' If the no button was pressed ...
If (result = DialogResult.No) Then
' cancel the closure of the form.
e.Cancel = True
End If
End Sub
설명
이 열거형은 클래스에서 MessageBox 사용됩니다.