Ticket CQ60337
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Calendar week & Month

Control for selecting month

created 18 years ago

Like in https://devexpress.com/issue=CQ60183 and https://devexpress.com/?issue=CS52224 we need a control for selecting a month & year. To be consistent with a day selection we would like to use a DateEdit in the Vista mode for this (like standard DateEdit but the popup should close as soon as a month is selected instead of zooming into the day view).
Do you already plan to implement this behavior or is there any possibility to implement this ourselves in an inherited control?
Thank you
Pascal

Comments (2)
DevExpress Support Team 18 years ago

    Hi Pascal,
    We don't currently provide a control which would be useful in this instance. As I see, you are tracking the suggestion you mentioned (ID: CS52224), so you'll be notified as soon as it is implemented.
    For now, the only solution we can suggest to you is to imitate this functionality using the approach Alex suggested in the report ID: CQ60183 (www.devexpress.com/issue=CQ60183). At the moment, this seems to be the best way to accomplish this task, sorry
    Thanks,
    Vito

      Hi Vito,
      Thank you for your response. Unfortunately the solution provided in https://www.devexpress.com/issue=CQ60183 is for several reasons (mainly GUI issues) no solution for us. What we need is the following:
        - A DateEdit with VistaDisplayMode = True
        - The DateEdit has a mask set for only displaying month and year of the selected date
        - As soon as the user clicks on a month in the popup window the date should be selected (for example the first of the selected month) and the popup closed
      As you see nearly everything is already here and possible with the current DateEdit. The only thing missing is the part of closing the popup of the DateEdit as the user selects a month. Is there really no possibility to hook into the DateEdit to make this possible? Should be no big deal… Implementing this in an inherited control would also be fine for us.
      Thank you
      Pascal

      Answers approved by DevExpress Support

      created 18 years ago (modified 11 years ago)

      Hi Pascal,
      Thank you for providing additional information. I now understand the functionality you wish to achieve.
      Yes, the only way to accomplish this task is to write a descendant of the DateEdit class.
      First, you should write a descendant of the VistaDateEditCalendar class and override its OnItemClick method in order to close the editor's popup form when clicking a month cell. Please also override the Init method and set the View property value to DateEditCalendarViewType.YearInfo:

      C#
      public class MyVistaDateEditCalendar : VistaDateEditCalendar { public MyVistaDateEditCalendar(RepositoryItemDateEdit item, object editDate) : base(item, editDate) { } protected override void Init() { base.Init(); this.View = DateEditCalendarViewType.YearInfo; } public override void OnItemClick(DevExpress.XtraEditors.Calendar.CalendarHitInfo hitInfo) { DayNumberCellInfo cell = hitInfo.HitObject as DayNumberCellInfo; if (View == DateEditCalendarViewType.YearInfo) { DateTime dt = new DateTime(DateTime.Year, cell.Date.Month, CorrectDay(DateTime.Year, cell.Date.Month, DateTime.Day), DateTime.Hour, DateTime.Minute, DateTime.Second); OnDateTimeCommit(dt, false); } else base.OnItemClick(hitInfo); } }

      Then, it is required to write a custom PopupDateEditForm, and override its CreateCalendar method in order to use this kind of calendar:

      C#
      public class MyVistaPopupDateEditForm : VistaPopupDateEditForm { public MyVistaPopupDateEditForm(DateEdit ownerEdit) : base(ownerEdit) { } protected override DateEditCalendar CreateCalendar() { return new MyVistaDateEditCalendar(OwnerEdit.Properties, OwnerEdit.EditValue); } }

      Finally, please write a descendant of the DateEdit class and override its CreatePopupForm method:

      C#
      public class MyDateEdit : DateEdit { protected override PopupBaseForm CreatePopupForm() { if (Properties.VistaDisplayMode == DevExpress.Utils.DefaultBoolean.True) return new MyVistaPopupDateEditForm(this); return new PopupDateEditForm(this); } }

      I believe this information will be of some help. Please keep us informed of your progress.
      Thanks,
      Vito

        Show previous comments (2)
        GP GP
        Grégoire Perruchoud 11 years ago

          7 years old and still relevant. Works like a charm, thanks !

            thanks!it is very helpful.

            M M
            Michael Proctor [DX-Squad] 9 years ago

              Just figured I would post that this is now broken in 15.2 due to changes to DateEdit with the CalendarControl.
              Look at https://www.devexpress.com/Support/Center/Question/Details/T320602 for some updated code (although it is a bit incomplete). Will post an update when I finish playing with the changes.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.