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

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

    • Post Options:
    • Link

    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]
  • Posted 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

  • Posted 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.

  • Posted 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

  • Posted 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

  • Posted 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.

  • Posted 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

  • Posted 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.

  • Posted 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

  • Posted 16 April 2020, 10:16 pm EST - Updated 3 October 2022, 11:46 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.

  • Posted 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

  • Posted 20 April 2020, 3:13 pm EST

    In this case I want to close my pop-up window on which this control is added.

  • Posted 20 April 2020, 3:30 pm EST

    Hello,

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

    Thanks,

    Mohit

  • Posted 21 April 2020, 6:59 pm EST

    A simple wpf window. On this window I have this datetime piker control.

  • Posted 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

  • Posted 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.

  • Posted 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

  • Posted 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.

  • Posted 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.

  • Posted 19 July 2020, 9:45 pm EST - Updated 3 October 2022, 11:47 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.

  • Posted 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

  • Posted 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.

  • Posted 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

  • Posted 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();

    }

  • Posted 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();

    }

  • Posted 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

  • Posted 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.

  • Posted 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

  • Posted 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.

  • Posted 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

  • Posted 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.

  • Posted 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.

  • Posted 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

  • Posted 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.

  • Posted 6 August 2020, 5:32 pm EST

    Hi Mayur,

    This is an expected behavior. If you try to parse “000000” using TimeSpan.Parse(“000000”) you will get the same result as “000000” here represents the number of days in the TimeSpan object.

    Same goes with “000001” as the 1 added in front of the result is the number of days in the TimeSpan object.

    Regards,

    Basant

  • Posted 25 August 2020, 5:07 pm EST

    [quote]1. For time editor , I did not find FinalizeEditing method.

    [/quote]

    Hi Mayur,

    This is to inform you that C1TimeEditor now (in 2020v2 HotFix 1) exposes FinalizeEditing() methd which can be used to explicitly validate the editor value. Please find the latest builds from the following link:

    http://prerelease.componentone.com/hotfixes/wpf/C1WPFBasicLibrary.4.5.2_4.5.20202.719.zip

    Regards,

    Basant

  • Posted 26 August 2020, 11:25 pm EST

    Dear Team,

    When I input the value as 08:0040 then it automatically coinages to 08:40:00 but when I enter “08:3000" it returns to the state (“08:00:00”) .

    I did the settings same as discussed in above thread. Is there any way to correct this or this is also a default behavior of Timespan.parse().

  • Posted 27 August 2020, 5:30 pm EST

    Hi Mayur,

    As you are inputting time in HH:mm format which means 0040 in 08:0040 denotes minutes and 40 is a valid value for minutes. Hence it gets parsed.

    However when you are inputting 08:3000 where 3000 is an invalid value for minutes because max value for minutes can be 59 and therefore it reverts back to previous valid state.

    You can verify the same from below code:

    var t1 = TimeSpan.Parse("08:0040");
    var t2 = TimeSpan.Parse("08:3000"); // Exception will be thrown here.
    
    

    When parsing 08:3000 you will get the following exception message:

    The TimeSpan could not be parsed because at least one of the numeric components is out of range or contains too many digits.

    So yes, this is the default and standard behavior.

    ~ Basant

  • Posted 3 September 2020, 9:13 pm EST

    Dear Team,

    Thank you for the answer.

    I am facing some inconsistent behavior and even able to reproduced it in sample solution provided from forum.

    Please find an attachment for the same sample solution.

    step 1: When I enter 14:0003 for the first time and press tab key then time changes 14:03:00 which is correct as per above explanation.

    step 2: Now after this I again go to same time box using mouse and remove “3:” and now string is 14:000 then I add 3 now it is 14:0003 now I press tab key there s no change in GUI. it is displaying 14:0003 event though focus is lost. It should display 14:03:00 similar like step 1.

    If it is a bug and need some time for fixing it, I need the technical reason to close this bug in our project.

    file-f1ceafe4-7e97-4102-aa55-f4a8d50fa819.zip[img]https://gccontent.blob.core.windows.net/forum-uploads/file-e14a0798-3326-46e4-9030-93a13d524298.PNG[/img]

  • Posted 4 September 2020, 12:47 am EST

    Hi Mayur,

    TimeEditor updates the displayed time when there is any change in its Value property or in case of validation error.

    Since the underlying value of 14:0003 during the 2nd step is unchanged (i.e. 14:00:03) and hence the displayed text is not updated. However, I have escalated it to the devs (Internal Track Id: 461551) as this seems to be a bug.

    If required, as a workaround, you can use the LostFocus event of TimeEditor’s MaskedTextBox as follows:

    private void TimeEditorLoaded(object sender, RoutedEventArgs e)
    {
          var maskedTextBox = timeEditor.Template.FindName("TextBox", timeEditor) as C1MaskedTextBox;
          maskedTextBox.LostFocus += (s, o) =>
          {
                maskedTextBox.Text = timeEditor.Value.ToString();
           };
    }
    
    

    Please refer to the same from the attached modified sample.

    Regards,

    Basant

    DateTimeEditorsFinalizeEditing_Mod.zip

  • Posted 13 December 2020, 11:26 pm EST

    Hi Mayur,

    The above mentioned issue has been fixed in the latest release (i.e. 2020v3). You can upgrade to the latest version using C1ControlPanel from: https://www.grapecity.com/download/componentone-studio.

    Regards,

    Basant

Need extra support?

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

Learn More

Forum Channels