[C#] DateEdit Control 특정 날짜만 선택가능


DateEdit control 생성


-- 특정 날짜 이외에 disabled

private void dateEdit1_DrawItem(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e) {

        

//매주 월요일만 가능 || 오늘 이전 회색

if(e.Date.DayOfWeek != DayOfWeek.Monday) || (e.Date < Date.Now.Date)) {

           e.Style.ForeColor = Color.Gray;

}

}

private void dateEdit1_EditValueChanging(object sender,DevExpress.XtraEditors.Controls.ChangingEventArgs e) {

       if(Convert.ToDateTime(e.NewValue,System.Globalization.CultureInfo.InvariantCulture).DayOfWeek != DayOfWeek.Monday) || 

   (Convert.ToDateTime(e.NewValue,System.Globalization.CultureInfo.InvariantCulture) < Date.Now.Date)) {

          e.Cancel = true;

}

}




+ Recent posts