Mouse Wheel Operation for Date-Time-Picker control is in reverse order.

Posted by: mayur.purandare on 5 March 2020, 10:09 pm EST

  • Posted 5 March 2020, 10:09 pm EST

    Hello,

    Facing issue in DateTimePicker control.

    Mouse Wheel Operation for Date-Time-Picker control is in reverse order for Date and Time controls
    Date:
    1. If Mouse wheel is scrolled Down (↓) then Date is incremented. [OK]
    2. If Mouse wheel is scrolled Up (↑) then Date is decremented. [OK]

    Time:
    1. If Mouse wheel is scrolled Down (↓) then Time is decremented. [NG]
    2. If Mouse wheel is scrolled Up (↑) then Time is incremented. [NG]
  • Replied 8 March 2020, 5:50 pm EST

    Hello,

    I have escalated this to our development team(424272) and will inform you once I got any information from them.

    Thanks,
    Mohit
  • Replied 10 March 2020, 9:44 pm EST

    Hello,

    Is there any update on this?
    If this bug needs to be fixed in Component One, when can we get a release for this as we have planned to release our product on 13th March 2020?
    Please do the needful.
  • Replied 11 March 2020, 5:47 pm EST

    Hello,

    I have asked the dev team for the ETA on this issue and will inform you once I got any reply from them.

    Thanks,
    Mohit
  • Replied 16 March 2020, 8:11 pm EST

    Hello,

    We replied the query on the following link:
    https://supportone.componentone.com/home/casedetail/425690

    Please use the Forum credential to login to the SupportOne our private forum.

    Thanks,
    Mohit
  • Replied 13 April 2020, 5:54 pm EST

    Dear Team,

    My requirement is whenever I press Enter Key on my pop-up window should be closed. For all other controls this is working properly.

    But for date and time control, whenever enter is pressed that date or time is selected, but pop-up is not getting closed.

  • Replied 14 April 2020, 5:52 pm EST

    Hello,

    I am not able to reproducible the issue at my end. I selected the date in dropdown and press enter. Could you please confirm if I am missing something at my end.

    Thanks,
    Mohit
  • Replied 15 April 2020, 5:52 pm EST

    Hi,

    It is not abt selecting date through calendar. It is just that we put mouse cursor in date or time control and press enter key.
  • Replied 16 April 2020, 12:54 am EST

    Hello,

    I am not able to reproduce with the following steps:
    1: Open the DropDown
    2: Hover the mouse over date time control
    3: Press Enter

    Please confirm if I am something.

    Thanks,
    Mohit
  • Replied 16 April 2020, 10:16 pm EST

    1. Added one date time picker control.
    2. Go to Time field. Now cursor is in time field.
    3. Press enter. Whole time string gets selected.

    Please find an attached image.
  • Replied 19 April 2020, 11:31 pm EST

    Hello.

    I am able to reproduce this with the given steps. However, could you please confirm what is the expected behavior in this,

    Thanks,
    Mohit
  • Replied 20 April 2020, 3:13 pm EST

    In this case I want to close my pop-up window on which this control is added.
  • Replied 20 April 2020, 3:30 pm EST

    Hello,

    Could you please tell what do you mean by "Pop up window" here.

    Thanks,
    Mohit
  • Replied 21 April 2020, 6:59 pm EST

    A simple wpf window. On this window I have this datetime piker control.
  • Replied 21 April 2020, 9:09 pm EST

    Hello,

    You can use PreviewKeyDown event to close the window on Key press

    private void Dtp_PreviewKeyDown(object sender, KeyEventArgs e)
    {
    if(e.Key == Key.Enter)
    {
    this.Close();
    }
    }


    If I am still missing something, please share the demo application so that I can look into the issue.

    Thanks,
    Mohit
  • Replied 22 April 2020, 7:49 pm EST

    Yes it is working when I keep mouse cursor in date field, y window gets closed.
    But Now If I open calendar from date field to select date and I pressed enter it is closing window.
    So when calendar is open it should select date and on enter press and when calendar is closed and mouse cursor is present in date field then it should closed pop-up.
  • Marked as Answer

    Replied 23 April 2020, 5:25 pm EST

    Hello,

    You check in the condition that dropdown of datetimepicker is open or not using the following line of code:
    private void Dtp_PreviewKeyDown(object sender, KeyEventArgs e)
    {
    if(e.Key == Key.Enter && !dtp.IsDropDownOpen)
    {
    this.Close();
    }
    }


    Thanks,
    Mohit
  • Replied 7 June 2020, 6:45 pm EST

    Dear Team,

    How to remove context menu from Date time editor. By setting context menu = null it is disabled but not removed.
  • Replied 9 June 2020, 6:24 pm EST

    Hi Mayur,

    Please handle the PreviewMouseRightButtonUp event on C1DateTimePicker as follows:
    private void DateTimeEditorPreviewMouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
    e.Handled = true;
    }


    Regards,
    Basant.
  • Replied 19 July 2020, 9:45 pm EST

    Dear Team,

    I have new query related to DateTimeCntrol.

    My AppIication supports Japanese and English Language.
    I have customized context menu for Cut, Copy, Paste and their respective japanese string.
    When I right click on DropDown arrow or corners of Datetime control proper japanese context menu is displayed but hen I click on text and right click on it then English contxt menu is displayed even though selected language is japanese.
  • Replied 20 July 2020, 10:23 pm EST

    Hi Mayur,

    The ContextMenu with English language is the default context menu of C1DateTimePicker control's TextView. You can override the default ContextMenu by using the C1DateTimePicker's PreviewMouseRightButtonUp event handler as follows:

    private void C1DateTimePicker_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
    {
    (_dateTimePicker.ContextMenu as ContextMenu).IsOpen = true;
    }


    Regards,
    Basant
  • Replied 22 July 2020, 1:59 am EST

    Dear Team,

    Thank you for the reply. It works correctly.

    I have these datetime controls and I have one save button to save the settings.
    When i entered/typed any wrong values like 61 seconds and day is 99 and pressed the save button wrong values gets auto corrected.

    But that save button has short cut keys and when I entered wrong datetime and cursor/focus is in datetime control only and if I press short cut keys, then save button function gets called but date time control values are not getting corrected automatically.

    There is behavior difference in Mouse event and key pressed event.

  • Replied 22 July 2020, 6:50 pm EST

    Hi,

    C1DateTimePicker validates the entered DateTime when focus is lost. Therefore when you press the Save button, Focus is changed from DateTimePicker to save button and the DateTime is validated.
    But when you use shortcut keys the focus remains on the C1DateTimePicker and hence DateTime is not validated. Howeve, In that case, you can manually validate the entered DateTime by calling the DateTimePicker's FinalizeEditing method before the Save method as follows:

    if(Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.S)
    {
    _dateTimePicker.FinalizeEditing();
    Save();
    }


    Also, I would request you to create a new case for a new query. It would help us to keep a thread focusing on a single issue and easy to understand.

    Regards,
    Basant
  • Replied 22 July 2020, 10:56 pm EST

    Sorry for the wrong information.
    My problem is same but I am not using datetimecontrol but I am using C1DatePicker and C1TimeEditor control.

    Queries:
    1. For time editor , I did not find FinalizeEditing method.
    2. For date picker control, I have handled PreviewKeyDown event, but is not working properly. I have written two if cases for verification but both the if cases are not working. is it correct.

    if (e.Key == Key.LeftAlt && e.Key == Key.F)
    {
    endDate.FinalizeEditing();
    }
    if (e.SystemKey == Key.LeftAlt && e.Key == Key.F)
    {
    endDate.FinalizeEditing();
    }
  • Replied 22 July 2020, 10:56 pm EST

    Sorry for the wrong information.
    My problem is same but I am not using datetimecontrol but I am using C1DatePicker and C1TimeEditor control.

    Queries:
    1. For time editor , I did not find FinalizeEditing method.
    2. For date picker control, I have handled PreviewKeyDown event, but is not working properly. I have written two if cases for verification but both the if cases are not working. is it correct.

    if (e.Key == Key.LeftAlt && e.Key == Key.F)
    {
    endDate.FinalizeEditing();
    }
    if (e.SystemKey == Key.LeftAlt && e.Key == Key.F)
    {
    endDate.FinalizeEditing();
    }
  • Replied 23 July 2020, 8:35 pm EST

    Hi Mayur,

    1) Yes, there is no such method for TimeEditor yet. However, I have raised an enhancement request for the same (TFS ID: 454790) and will inform you for any update.

    However, as a workaround, you can validate the C1TimeEditor value as follows:
    private void FinalizeTimeEditorEditing()
    {
    var maskedTextBox = timeEditor.Template.FindName("TextBox", timeEditor) as C1MaskedTextBox;
    string[] formats = new string[] { "hh:mm:ss tt", "h:m:s tt", "hh:mm:ss", "h:m:s" };
    if (!DateTime.TryParseExact(maskedTextBox.Text, formats, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out DateTime time))
    {
    TimeSpan timeSpan = timeEditor.Value.Value;
    maskedTextBox.Text = new DateTime().Add(timeSpan).ToLongTimeString();
    }
    else
    {
    timeEditor.Value = time.TimeOfDay;
    }
    }


    Just in case, You can alternatively use the C1DateTimePicker (which provides FinalizeEditing() method) and specify to show only DatePicker, TimeEditor or both by using its EditMode property.
    For example:
    // For showing only DatePicker
    dateTimePicker.EditMode = C1DateTimePickerEditMode.Date

    // For showing only TimeEditor
    dateTimePicker.EditMode = C1DateTimePickerEditMode.Time

    2) Please use the condition as follows:
    if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.F)
    {
    datePicker.FinalizeEditing();
    }


    Regards,
    Basant
  • Replied 25 July 2020, 5:01 am EST

    Dear Team,

    Thanks for the solution i will try and let u know the results.

    For my earlier query related to context menu below solution is provided.

    The ContextMenu with English language is the default context menu of C1DateTimePicker control's TextView. You can override the default ContextMenu by using the C1DateTimePicker's PreviewMouseRightButtonUp event handler as follows:

    private void C1DateTimePicker_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
    {
    (_dateTimePicker.ContextMenu as ContextMenu).IsOpen = true;
    }


    I have tried this solution and it shows the proper text. But when I select text and right click Cut option is not enabled. All options are disabled.
    Before applying this solution it was working.
  • Replied 26 July 2020, 6:09 pm EST

    Hi Mayur,

    Sorry for the inconvenience. However, Please also set the PlacementTarget property of DatePicker's ContextMenu as follows:

    private void datePicker_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
    {
    datePicker.ContextMenu.IsOpen = true;
    datePicker.ContextMenu.PlacementTarget = datePicker;
    }


    Regards,
    Basant
  • Replied 27 July 2020, 8:21 pm EST

    Dear Team,

    I have requirement to close the pop-up when user pressed enter and I got the below reply from forum in this thread only.

    if (e.Key == Key.Enter && !string.IsNullOrEmpty(((C1.WPF.C1MaskedTextBox)e.OriginalSource).Text))
    {
    this.close();
    }

    Now when I changed the time and pressed enter my pop-up gets closed but updated value is not saved. Also I have tried to call the method method from above answer FinalizeTimeEditorEditing.

    if (e.Key == Key.Enter && !string.IsNullOrEmpty(((C1.WPF.C1MaskedTextBox)e.OriginalSource).Text))
    {
    startTime_FinaliseEditing();
    this.close();
    }

    But still it does not save the updated value.
  • Replied 28 July 2020, 8:31 pm EST

    Hi Mayur,

    The same is working fine at my end as TimeEditor's value is updating properly when closing popup window.
    Please refer to the sample attached below and please confirm if there is something specific needs to be done to replicate this behavior.

    Regards,
    Basant

    DateTimeEditorsFinalizeEditing.zip
  • Replied 30 July 2020, 8:51 pm EST

    Dear Team,

    I have tried the sample solution provided. But in this sample also same problme exist.
    If I enter the time as 13:00:00 then in message box it displays as 00:00:00 it should show 13:00:00.

  • Replied 30 July 2020, 8:51 pm EST

    Dear Team,

    I have tried the sample solution provided. But in this sample also same problme exist.
    If I enter the time as 13:00:00 then in message box it displays as 00:00:00 it should show 13:00:00.

  • Replied 3 August 2020, 9:29 pm EST

    Hi Mayur,

    TimeEditor uses 12 hour format by default. And the time you are providing is in 24 hour format. So, you have to set the TimeEditor's Format property to custom to enable the 24 hour format and then specify the CustomFormat as 'HH:mm:ss [tt]':
    <c1:C1TimeEditor x:Name="timeEditor" Format="Custom" CustomFormat="HH:mm:ss"  Height="30" Width="150"/>

    Also, add "HH:mm:ss [tt]" to the formats inside FinalizeEditing method so that it can be validated correctly. Please refer to the attached modified sample.

    Regards,
    Basant

    DateTimeEditorsFinalizeEditing_mod.zip
  • Replied 5 August 2020, 9:08 pm EST

    After doing all the setting from above thread, when I enter 000000(6 zeros), it automatically changes to 00:00:00 .

    Also when i edit and enter 5 zeros and 1 like 000001 it chnages to 1.00:00:00.

  • Replied 5 August 2020, 9:08 pm EST

    After doing all the setting from above thread, when I enter 000000(6 zeros), it automatically changes to 00:00:00 .

    Also when i edit and enter 5 zeros and 1 like 000001 it chnages to 1.00:00:00.

  • Replied 5 August 2020, 9:08 pm EST

    After doing all the setting from above thread, when I enter 000000(6 zeros), it automatically changes to 00:00:00 .

    Also when i edit and enter 5 zeros and 1 like 000001 it chnages to 1.00:00:00.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels