Search code examples
c#calendardevexpress

How can I show only the years with a DateEdit in C# with DevExpress?


I want to show a calendar with years only, not days nor months. Preferably with the DateEdit that DevExpress provides.


Solution

  • You can accomplish this task by handling the DateEdit.Popup event:

    private void dateEdit1_Popup(object sender, EventArgs e)
        {
            DateEdit edit = sender as DateEdit;
            PopupDateEditForm form = (edit as IPopupControl).PopupWindow as PopupDateEditForm;
            form.Calendar.View = DevExpress.XtraEditors.Controls.DateEditCalendarViewType.YearInfo;
        }
    

    more info here