string name = txtName.Text;
string studentId = txtStudentId.Text;
string phone = txtPhone.Text;
TextBox는 무조건 .Text
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(studentId))
null 또는 빈 문자열 체크
MessageBox.Show("메시지", "제목", MessageBoxButton.OK, MessageBoxImage.Warning);
구성
if (cmbDepartment.SelectedItem is ComboBoxItem seleted)
{
dept = seleted.Content.ToString();
}
선택된 항목 → SelectedItem
실제 값 → Content
string birth = dpBirthday.SelectedDate?.ToString("yyyy-MM-dd") ?? ("미등록");
SelectedDate → nullable(DateTime?)
?. → 값 있으면 실행
?? → null이면 대체값
날짜 있으면 → 포맷 변환
없으면 → "미등록"
txtName.Text = "";
cmbDepartment.SelectedIndex = -1;
dpBirthday.SelectedDate = null;
TextBox → ""
ComboBox → -1 (선택 해제)
DatePicker → null
txtName.Focus(); //커서를 이름칸으로 이동
열공이넹!
ㅎ히히 멋잇엉
머시다 머시다 예서오바멋잇다~