DropDownList MouseWheel Behavior in C# Outlook VSTO Add-in

12 posts, 1 answers
  1. reed
    reed avatar
    4 posts
    Member since:
    Apr 2018

    Posted 30 Apr 2018 Link to this post

    I have a C# Outlook VTSO Add-in project that has issue regarding the behavior of the comboboxcolumn in a datagrid when using the mousewheel. The item just jumps to the first or last item when scrolling using the mousewheel, and also when pressing the up or down arrow while the dropdownlist is visible.

    I tried to replicate the issue on a new Telerik C# Windows Forms Application but it seems that the issue only exist for C# Outlook VTSO Add-in projects. What I did was to add a dropdownlist and add more than 20 items and tried scrolling using the mouse wheel on both win form app and vtso addin. The issue only exist on the vtso addin.

    Are there any workarounds about this?

    Attached here are screen capture of outlook vtso addin and another for telerik windows form.

  2. Hristo
    Admin
    Hristo avatar
    1522 posts

    Posted 30 Apr 2018 Link to this post

    Hello Reed,

    Thank you for writing.

    I tested a similar setup and the drop-down editor of the GridViewComboBoxColumn behaved correctly in my sample project. For reference, I am attaching it to the thread as well as a short video showing the result on my end.

    In your video, I see that there is a certain delay while opening the popup. Please note that COM/ActiveX projects and Outlook add-ins are having a different application lifecycle and message loop compared to a standard .NET application. In such scenarios it possible to observe certain differences compared to a standard .NET project. Regarding your actual setup, disabling the animations might help so you can set the static AllowAnimations property to false: 
    ThemeResolutionService.AllowAnimations = false;

    I hope this helps. Let me know if you have other questions.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. reed
    reed avatar
    4 posts
    Member since:
    Apr 2018

    Posted 15 May 2018 in reply to Hristo Link to this post

    Hi Hristo,

    Thank you for replying.

    I downloaded the project you attached and tried your setup. It seems the issue still persist on my side. I also tried to set the static AllowAnimations property to false on my setup and the actual project, but the issue is not resolved. Does this have something to do with the telerik version?

    I attached the screenshot of the version of my setup here.

  4. Hristo
    Admin
    Hristo avatar
    1522 posts

    Posted 16 May 2018 Link to this post

    Hello Reed,

    The version of the suite does not appear to be related as I have tested the 2016 dlls as well as the latest ones. I am not able to observe the reported on your end behavior. Please note, that Office add-ins are having a different application lifecycle and message loops compared to standard .NET applications. In this respect, there might be differences when you use the controls in add-ins.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. reed
    reed avatar
    4 posts
    Member since:
    Apr 2018

    Posted 24 May 2018 in reply to Hristo Link to this post

    Hi Hristo,

    If Office add-ins are having a different application lifecycle and message loops compared to standard .NET applications, and the "possibility" of differences when i used the controls in add-ins, how come you can not replicate the issue and in my end the issue still persist even if i downloaded and tried your sample project? What are the possibilities that the same projects does not have the same behavior? Have you tried replicating the issue without disabling the animations? Because I tried the sample project that you attached in your previous post in this thread and in my end the issue still persist.
  6. Answer
    Hristo
    Admin
    Hristo avatar
    1522 posts

    Posted 28 May 2018 Link to this post

    Hi Reed,

    Before sending you the project I tested it with and without the animations. The behavior on my end is the same and the drop-down list can be scrolled one item at a time. Can you please try installing the add-in on a different system? The issue might be Office or machine related. There is not much that can be done on our end. We do not have code specifically handling add-in scenarios.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. reed
    reed avatar
    4 posts
    Member since:
    Apr 2018

    Posted 31 May 2018 in reply to Hristo Link to this post

    Hi Hristo,

     

    Before posting to Telerik Forums our QA team verified that the issue persist in their machine. 

    Thank you for that. I guess the only option and work around we could do is to use DataGridView instead of Telerik RadGridView.

     

    Regards,

    Reed

  8. Hristo
    Admin
    Hristo avatar
    1522 posts

    Posted 01 Jun 2018 Link to this post

    Hi Reed,

    Thank you for writing back.

    As we are not able to reproduce the reported behavior it is really hard to determine its actual cause. We also do not have control over the add-in scenario and the Outlook environment so indeed there is not much that we can do on our end. 

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  9. David
    David avatar
    7 posts
    Member since:
    Jun 2019

    Posted 03 Feb 2020 Link to this post

    I'm experiencing the exact behavior as the original poster. The mouse wheel causes scrolling to jump to the end of the list or to the top of the list when using the RadDropDownList, as well as the RadCheckedDropDownList, within an Office add-in. Was there any solution found for this issue?

    Or is there a way to override the mouse wheel event for the dropdownlist element and simulate it in code?

  10. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4127 posts

    Posted 04 Feb 2020 Link to this post

     

    Hello, David,   

    Please note that as my colleague, Hristo, previously noted, COM/ActiveX projects and Outlook add-ins are having a different application life-cycle and message loop compared to a standard .NET application. In such scenarios it is possible to observe certain differences compared to a standard .NET project. Please note that we do not test our controls in such an environment and we do not guarantee normal work of the controls.

    Have you tried the suggested solution with disabling the animation? Is the scrolling problem still reproducible?

    According to the provided information, I am not sure whether you use the drop down list in RadGridView as an editor or as a separate control. However, in both cases you may use a similar approach for preventing the mouse wheel behavior.

    RadGridView uses a RadDropDownListEditor for the combo columns. In order to disable scrolling the items in the popup, it is necessary to return true in the DropDownPopupForm.OnMouseWheel event. However, you will still be able to scroll the editable part in RadDropDownList. This can be stopped by overriding the RadDropDownListEditorElement.OnMouseWheel event and leaving the method empty. Then replace the default editor with the custom one in the EditorRequired event: https://docs.telerik.com/devtools/winforms/controls/gridview/editors/using-custom-editors

     public class CustomRadDropDownListEditor : RadDropDownListEditor
            {
                protected override RadElement CreateEditorElement()
                {
                    return new CustomRadDropDownListEditorElement();
                }
            }
    
            public class CustomRadDropDownListEditorElement : RadDropDownListEditorElement
            {
                protected override RadPopupControlBase CreatePopupForm()
                {
                    this.Popup = new CustomDropDownPopupForm(this);
                    return Popup;
                }
                protected override void OnMouseWheel(MouseEventArgs e)
                {
     
                }
            }
    
            public class CustomDropDownPopupForm : DropDownPopupForm
            { 
                public CustomDropDownPopupForm(RadDropDownListElement ownerDropDownListElement) 
                    : base(ownerDropDownListElement)
                {
                }
    
                public override bool OnMouseWheel(Control target, int delta)
                {
                    return true;
                }
            }

    For RadDropDownList, you can stop the default mouse wheel logic and implement your own as follows:

            public class CustomDropDownList : RadDropDownList
            {
                public override string ThemeClassName
                {
                    get
                    {
                        return typeof(RadDropDownList).FullName;
                    }
                }
    
                protected override RadDropDownListElement CreateDropDownListElement()
                {
                    return new CustomRadDropDownListElement();
                }
            }
    
            public class CustomRadDropDownListElement : RadDropDownListElement
            {
                protected override Type ThemeEffectiveType
                {
                    get
                    {
                        return typeof(RadDropDownListElement);
                    }
                }
    
                protected override void OnMouseWheel(MouseEventArgs e)
                { 
                }
    
                protected override RadPopupControlBase CreatePopupForm()
                {
                    this.Popup = new CustomDropDownPopupForm(this);
                    return Popup;
                }
            }
    
            public class CustomDropDownPopupForm : DropDownPopupForm
            {
                public CustomDropDownPopupForm(RadDropDownListElement ownerDropDownListElement) : base(ownerDropDownListElement)
                {
                }
    
                public override bool OnMouseWheel(Control target, int delta)
                {
                    return true;
                }
            }

    If you are still experiencing any further difficulties, feel free to submit a support ticket from your account and provide a sample project demonstrating the undesired behavior hat you are facing. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance. Thank you in advance.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  11. David
    David avatar
    7 posts
    Member since:
    Jun 2019

    Posted 04 Feb 2020 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hi Dess,

    Thanks for your reply. I did try disabling the animation, but that didn't help. I finally pin-pointed the issue and have implemented a workaround until this issue can be fixed. It seems the OnMouseWheel event is being fired 3x for each mouse wheel delta turn event the mouse driver sends. So, if the mouse driver sends three deltas per notch, then each delta event is in turn multiplied by 3, thus raising a total of 9 OnMouseWheel events in rapid succession, causing the list to jump much further than it should. My solution was to reduce these back down to one event that gets passed-through per three events that are actually raised. Here is my code which does that, and I have attached a screenshot of all the classes used, similar to your examples above:

     

    class TwDropDownPopupForm : DropDownPopupForm
    {
    private const int EventsPerDelta = 3;
    private int eventCounter = 0;

    public TwDropDownPopupForm(RadDropDownListElement ownerDropDownListElement) : base(ownerDropDownListElement)
    {
    }

    /* 
    * This override is necessary because of a mouse wheel scrolling issue with this Telerik element
    * within an Office add-in host environment. The issue is that three OnMouseWheel events are
    * fired in rapid succession per mouse wheel notch (delta). So, if the mouse driver raises three
    * mouse wheel deltas, then each is multiplied by three events making a total of 9 OnMouseWheel 
    * events being fired in rapid succession. The code below will reduce it back down to just one
    * event that gets passed-through per three that are raised.
    */
    public override bool OnMouseWheel(Control target, int delta)
    {
    if (++eventCounter / EventsPerDelta == 1)
    {
    eventCounter = 0;
    return base.OnMouseWheel(target, delta); ;
    }
    return true;
    }
    }

  12. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4127 posts

    Posted 06 Feb 2020 Link to this post

    Hello, David,   

    I am glad that you have found a suitable solution for your scenario.

    The different environment (Office Add-in) doesn't guarantee that the same number of MouseWheel messages will be received in RadDropDownList. Hence, the obtained behavior.

    We already have a similar issue logged in our logged it in our feedback portal. You can track its progress, subscribe for status changes and add your comments on the following link  : https://feedback.telerik.com/winforms/1370581-fix-raddropdownlist-scrolling-with-the-mousewheel-or-down-arrow-key-jumps-from-the-first-to-the-last-item-in-word-add-in-when-the-popup-is-opened 

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top