RadGridView GridViewComboBox Column disable the mouse wheel

9 posts, 0 answers
  1. David
    David avatar
    5 posts
    Member since:
    Oct 2019

    Posted 28 Oct 2019 Link to this post

    Dear Sir/Madam,

    In My GridView, there's a GridViewComboBox. The problem I'm facing now is when I use mouse wheel to scroll the combobox via the dropdown list inside the combobox, my system crashes, but if I use the vertical scroll bar, the system is fine. Therefore I would like to disable the mouse wheel in the combobox.

    Could you give me some instructions?

    Thanks & Regards,

    David
  2. Nadya
    Admin
    Nadya avatar
    378 posts

    Posted 29 Oct 2019 Link to this post

    Hello David,

    In order to disable the mouse wheel in the GridViewComboBoxColumn, you can set the EnableMouseWheel property of the RadDropDownListEditorElement to false. This can be done in the CellEditorInitialized event when the initialization of an editor is done:

    private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadDropDownListEditor editor = this.radGridView1.ActiveEditor as RadDropDownListEditor;
        if (editor != null)
        {
            RadDropDownListEditorElement element = editor.EditorElement as RadDropDownListEditorElement;
            element.EnableMouseWheel = false;
        }
    }
    

    I hope this helps. Should you have any other questions, I will be glad to help.

    Regards,
    Nadya
    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.
  3. David
    David avatar
    5 posts
    Member since:
    Oct 2019

    Posted 30 Oct 2019 in reply to Nadya Link to this post

    Hi Nadya,
    Thanks for your reply.
    I used CellEditorInitialized event to set the EnableMouseWheel property to false, however my system still crashes.
    Also I tried to override it by catching mouse wheel event but in debugging mode It can't be hit.

    -- code --
    columnEditorElement.ListElement.MouseWheel += new MouseEventHandler(ListElement_MouseWheel);
    columnEditorElement.ListElement.VScrollBar.MouseWheel += new MouseEventHandler(VScrollBar_MouseWheel);
    -- code --

    Here is an attachement that shows when I clicked the combobox button then I used mouse wheel to scroll, my system crashed soon.
    To give you some additional information, my system is built on the Microsoft DyanmicsAX 2012.
    Is there anything else I should take into consideration before using mouse wheel or other event I have to consider?
    Thanks & Regards
    David
  4. Nadya
    Admin
    Nadya avatar
    378 posts

    Posted 30 Oct 2019 Link to this post

    Hello David,

    Thank you for the provided additional information. It was very helpful since I understand that you use Microsoft DynamicsAX. I was not able to reproduce this behavior on my end as we do not work under the Microsoft DynamicsAX environment. However, I can suggest setting the CallNextHookWhenNoDispatch property to false. The CallNextHookWhenNoDispatch property allows changing the default behavior of CallNextHookEx (by default it is true). You can set this property to false in order to keep the default hook behavior:

    RadMessageFilter.CallNextHookWhenNoDispatch = false;

    Please note that we do not test our controls in the DynamicsAX environment and we do not guarantee normal work of the controls because the message life-cycle is different in such a kind of environment.

    I hope this helps. Do not hesitate to contact us if you have other questions.

    Regards,
    Nadya
    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.
  5. David
    David avatar
    5 posts
    Member since:
    Oct 2019

    Posted 01 Nov 2019 in reply to Nadya Link to this post

    Thank you four your replay.
    Now I have sovled the problem of mousewheel via upgrade to the dlls of 2018_1_220 version.
    but I meet new problems now.
    It is that I used ResizeSelectionRectangle method which belongs GridRowBehavior originally,and it is gone now.
    Do you know how can I replace the method of ResizeSelectionRectangle?
    Do you know what is the function of the method of ResizeSelectionRectangle?Thank you four your replay.

     

  6. Nadya
    Admin
    Nadya avatar
    378 posts

    Posted 01 Nov 2019 Link to this post

    Hello David,

    Indeed, the selection rectangle is not available in the latest version of the Telerik UI for WinForms suite. It has been disabled and marked as obsolete in the specified version that you use 2018.1.220 and eventually removed in R2 2018 (version 2018.2.515). ResizeSelectionRectangle method has no alternative since the multiple selection in RadGridView has a brand new mechanism which is performed directly on the rows/cells with multiple selection: https://docs.telerik.com/devtools/winforms/controls/gridview/selection/multiple-selection

    Off topic, I would kindly ask you to open a separate thread in order to avoid mixing different subjects in the same thread in the future. This will also give you the opportunity to track the different cases easily in your account. Thank you for your understanding.

    Should you have any other questions do not hesitate to ask.

    Regards,
    Nadya
    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.
  7. David
    David avatar
    5 posts
    Member since:
    Oct 2019

    Posted 03 Nov 2019 in reply to Nadya Link to this post

    Hi Nadya,

    Thank you for your reply.

    Since the ResizeSelectionRectangle method was deleted in the version upgrade, I want to determine the impact scope and corresponding method of this method. But I didn't find the corresponding description in the API document, so can you ask about the original function of this method? I can use this to correspond.Thanks.

    In addition,  can you ask about the process of calling methods when the mouse scrolls in the drop-down list. Because there was an error in the old version and it was unable to catch the direct crash, but the error disappeared in the new version, so it is suspected that the location of the investigation was wrong. According to your answer, I can specifically lock the location of the crash, so as to investigate the cause. Thanks.

    Looking forward to your answer.

    Thanks & Regards,

    David

  8. David
    David avatar
    5 posts
    Member since:
    Oct 2019

    Posted 04 Nov 2019 in reply to Nadya Link to this post

    Hi Nadya,
    If I update my dlls from 2013 to 2018, I can disable the mousewheel action when I use the source of [element.EnableMouseWheel = false].
    With dlls of 2013,I can not disable the mousewheel action and the system will alert the error what I asked before.
    Do you know what happened ?
    And do you know what is the process action when I roll my mouse?
    Thanks & Regards,
  9. Nadya
    Admin
    Nadya avatar
    378 posts

    Posted 05 Nov 2019 Link to this post

    Hello David,

    If you are not able to set the EnableMouseWheel property I can suggest you to create custom editor and replace the default one. Then, create a custom RadDropDownListEditorElement with a custom DropDownPopupForm where you can override the OnMouseWheel method and change the default logic in order to prevent the basic logic for mouse wheel. The EditorRequired event is the appropriate place to replace the default editor with the custom one. Please refer to the following code snippet which demonstrates the described approach with the specified version 2013.1.312. The result is shown in the attached gif file.

     private void RadGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
     {
         if (e.EditorType==typeof(RadDropDownListEditor))
         {
             e.Editor = new CustomRadDropDownListEditor();
         }
     }
    
     private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
     {
         RadDropDownListEditor editor = this.radGridView1.ActiveEditor as RadDropDownListEditor;
         if (editor != null)
         {
             RadDropDownListEditorElement element = editor.EditorElement as RadDropDownListEditorElement;
            
             element.DropDownMinSize = new Size(50, 100);
    
             // element.EnableMouseWheel = false;
             element.ListElement.VScrollBar.Visibility = ElementVisibility.Collapsed;
             element.ListElement.VScrollBar.PropertyChanged -= VScrollBar_PropertyChanged;
             element.ListElement.VScrollBar.PropertyChanged += VScrollBar_PropertyChanged;
         }
     }
    
     private void VScrollBar_PropertyChanged(object sender, PropertyChangedEventArgs e)
     {
         if (e.PropertyName=="Visibility")
         {
             RadScrollBarElement scrollbar = sender as RadScrollBarElement;
             if (scrollbar.Visibility!= ElementVisibility.Collapsed)
             {
                     scrollbar.Visibility = ElementVisibility.Collapsed;
             }
         }
     }
    
     public class CustomRadDropDownListEditor : RadDropDownListEditor
     {
         protected override RadElement CreateEditorElement()
         {
             return new CustomDropDownListElement();
         }
     }
    
     public class CustomDropDownListElement: RadDropDownListEditorElement
     {
         protected override RadPopupControlBase CreatePopupForm()
         {
             this.Popup = new CustomDropDownForm(this);
             this.Popup.VerticalAlignmentCorrectionMode = AlignmentCorrectionMode.SnapToOuterEdges;
             this.Popup.SizingMode = this.DropDownSizingMode;
             this.Popup.Height = this.DropDownHeight;
             this.Popup.HorizontalAlignmentCorrectionMode = AlignmentCorrectionMode.Smooth;
             this.Popup.RightToLeft = this.RightToLeft ? System.Windows.Forms.RightToLeft.Yes : System.Windows.Forms.RightToLeft.Inherit;
             this.WirePopupFormEvents(this.Popup);
    
             return Popup;
         }
     }
     public class CustomDropDownForm : DropDownPopupForm
     {
         public CustomDropDownForm(RadDropDownListElement ownerDropDownListElement) : base(ownerDropDownListElement)
         {
         }
    
         public override bool OnMouseWheel(Control target, int delta)
         {
             return true; //pevent mouse wheel
             //instead set the RadDropDownListEditorElement.EnableMouseWheel property to false
         }
     }
    

    According to your question in your previous post about the ResizeSelectionRectangle method, I can say that this method was used to draw a specific rectangle over the selected cells and it did not affect the SelectedCells/SelectedRows collections if the rectangle is not shown. If you want to investigate it further I can suggest downloading the source code with the older version and see how it used to work. You can find a source.zip file in your account profile, section Downloads. The exact steps are described in the following help article: https://docs.telerik.com/devtools/winforms/installation-and-upgrades/download-product-files

    I hope this information helps. Let me know if I can assist you further.

    Regards,
    Nadya
    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