MessageBox validation
Caution
- 일반적인 경고 표시
- MessageBoxIcon 에 따라 보여주는 이미지 설정
if (string.IsNullOrWhiteSpace(text1.Text))
{
MessageBox.Show($"Select Item", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Confirm
- 클릭 이벤트 후 사용자에게 확인을 필요로 할 경우
- JS 의 confirm() 처럼 사용하고 싶은 경우
- DialogResult 값의 상황에 따라 처리할 수 있다.
private void confirmButton_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("Do you want to continue?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
// User clicked Yes, perform desired action
// For example: Save changes or proceed with an operation
}
else
{
// User clicked No, handle accordingly
// For example: Cancel the operation or do nothing
}
}
There might be incorrect information or outdated content.
'.NET > Winforms' 카테고리의 다른 글
| [WINFORMS][DevExpress] GridControl - GirdView.ColumnFilterChanged 컬럼 필터 이벤트 (0) | 2023.08.21 |
|---|---|
| [WINFORMS] form 데이터 전송 (0) | 2023.08.18 |
| [WINFORMS] Control.ControlCollection 메소드 (0) | 2023.08.16 |
| [WINFORMS] Tab Control (0) | 2023.08.16 |
| [WINFORMS] Text validation (0) | 2023.08.15 |