Current filter:
                                You should refresh the page.
                                  • Description:
                                    I am moving the mouse wheel to scroll the content of the XtraScrollableControl but nothing happens. How to resolve this issue?

                                    Answer:
                                    The cause of this shortcoming is that XtraScrollableControl cannot receive a focus as any container control. That is why, it is not scrolled when opening a form.
                                    When any child control is focused within XtraScrollableControl and you are moving the mouse wheel, the MouseWheel event is not implied to a parent container control and as a result, its content is not scrolled.
                                    You can easily overcome this shortcoming by using ScrollHelper. Just create a ScrollHelper instance and call the EnableScrollOnMouseWheel method for instance in the Form's/UserControl's Load event handler.
                                    Also, please note that if you dock a child control to XtraScrollableControl edges it is necessary to set the XtraScrollableControl.AutoScrollMinSize property to set the minimum size of the auto-scroll and thus to enable scrolling.
                                    Here is a sample code of this helper class:

                                    [C#]
                                    public class ScrollHelper { XtraScrollableControl scrollableControl; public ScrollHelper(XtraScrollableControl scrollableControl) { this.scrollableControl = scrollableControl; } public void EnableScrollOnMouseWheel() { scrollableControl.VisibleChanged += OnVisibleChanged; } void OnVisibleChanged(object sender, EventArgs e) { scrollableControl.Select(); UnsubscribeFromMouseWheel(scrollableControl.Controls); SubscribeToMouseWheel(scrollableControl.Controls); } private void SubscribeToMouseWheel(Control.ControlCollection controls) { foreach (Control ctrl in controls) { ctrl.MouseWheel += OnMouseWheel; SubscribeToMouseWheel(ctrl.Controls); } } private void UnsubscribeFromMouseWheel(Control.ControlCollection controls) { foreach (Control ctrl in controls) { ctrl.MouseWheel -= OnMouseWheel; UnsubscribeFromMouseWheel(ctrl.Controls); } } void OnMouseWheel(object sender, MouseEventArgs e) { DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true; int scrollValue = scrollableControl.VerticalScroll.Value; int largeChange = scrollableControl.VerticalScroll.LargeChange; if (e.Delta < 0) scrollableControl.VerticalScroll.Value += scrollableControl.VerticalScroll.LargeChange; else if (scrollValue < largeChange) scrollableControl.VerticalScroll.Value = 0; else scrollableControl.VerticalScroll.Value -= largeChange; } public void DisableScrollOnMouseWheel() { scrollableControl.VisibleChanged -= OnVisibleChanged; UnsubscribeFromMouseWheel(scrollableControl.Controls); scrollableControl = null; } }
                                    [VB.NET]
                                    Public Class ScrollHelper Private scrollableControl As XtraScrollableControl Public Sub New(ByVal scrollableControl As XtraScrollableControl) Me.scrollableControl = scrollableControl End Sub Public Sub EnableScrollOnMouseWheel() AddHandler scrollableControl.VisibleChanged, AddressOf OnVisibleChanged End Sub Private Sub OnVisibleChanged(ByVal sender As Object, ByVal e As EventArgs) scrollableControl.Select() UnsubscribeFromMouseWheel(scrollableControl.Controls) SubscribeToMouseWheel(scrollableControl.Controls) End Sub Private Sub SubscribeToMouseWheel(ByVal controls As Control.ControlCollection) For Each ctrl As Control In controls AddHandler ctrl.MouseWheel, AddressOf OnMouseWheel SubscribeToMouseWheel(ctrl.Controls) Next ctrl End Sub Private Sub UnsubscribeFromMouseWheel(ByVal controls As Control.ControlCollection) For Each ctrl As Control In controls RemoveHandler ctrl.MouseWheel, AddressOf OnMouseWheel UnsubscribeFromMouseWheel(ctrl.Controls) Next ctrl End Sub Private Sub OnMouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs) DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = True Dim scrollValue As Integer = scrollableControl.VerticalScroll.Value Dim largeChange As Integer = scrollableControl.VerticalScroll.LargeChange If e.Delta < 0 Then scrollableControl.VerticalScroll.Value += scrollableControl.VerticalScroll.LargeChange Else If scrollValue < largeChange Then scrollableControl.VerticalScroll.Value = 0 Else scrollableControl.VerticalScroll.Value -= largeChange End If End If End Sub Public Sub DisableScrollOnMouseWheel() RemoveHandler scrollableControl.VisibleChanged, AddressOf OnVisibleChanged UnsubscribeFromMouseWheel(scrollableControl.Controls) scrollableControl = Nothing End Sub End Class
                                Show all comments
                                • Irina Gubernskaya 07.26.2015

                                  Hi,
                                  I've tried your solution, it works when the application is loaded, but it stops working after collapsing a layout group.
                                  Steps to reproduce:

                                  1. Run the attached demo
                                  2. Notice that scrolling with mouse wheel works
                                  3. Collapse “Group”
                                  4. Notice that scrolling with mouse wheel does not work
                                  What should I do to make it work? And why can’t you implement this solution out-of-box?
                                • Nadezhda (DevExpress Support) 07.27.2015

                                  Hello,

                                  To process your recent post more efficiently, I created a separate ticket on your behalf: How to enable scrolling in XtraScrollableControl by using the mouse wheel when XtraScrollableControl is located inside LayoutControl. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

                                • UJ 05.02.2016

                                  I've an WinForm application with XtraScrollableContent with a FlowLayoutPanel. In this panel I add multiple UserControls. The suggested solution doesn't work at all. Any suggestions?

                                • Svetlana (DevExpress Support) 05.03.2016

                                  Hello,

                                  I've created a separate ticket on your behalf (T374145: XtraScrollableControl content is not scrolled). It has been placed in our processing queue and will be answered shortly.

                                • Maggie Canizales 06.21.2016

                                  How do you declare an instance of this class? I can't figure it out for the life of me.

                                  Thanks.

                                • Alexey Z (DevExpress Support) 06.22.2016

                                  Hello,

                                  I've created a separate ticket on your behalf (K18512: How to enable scrolling in XtraScrollableControl by using the mouse wheel - How do you declare an instance of this class?). It has been placed in our processing queue and will be answered shortly.

                                • Wolfgang Sigel 07.18.2017

                                  In terms of avoiding an EventHandler-Leak I would suggest to enhance the helper class by making it implement the IDisposable interface and add the following method:

                                  [C#]
                                  public void Dispose() { if (scrollableControl != null) scrollableControl.Dispose(); }

                                  Then when you don't need the resource any more you can call the Dispose() method on the ScrollHelper you've created before.
                                  I came across this when trying to resolve several EventHandler-Leaks in my application and it solved my problem in respect to this ScrollHelper-class.

                                  So in case someone detects the same problem.

                                • Svetlana (DevExpress Support) 07.19.2017

                                  Hi,

                                  This helper allows you to implement the additional functionality for XtraScrollableControl. That is why, disposing of this class object should not dispose of a bound XtraScrollableControl for which this helper is used. We have a special ScrollHelper.DisableScrollOnMouseWheel method, which should be called when this helper is unnecessary any longer. The only modification that is necessary to do in this helper class is to set the scrollableControl variable to null in the DisableScrollOnMouseWheel method. I have updated this helper class' code to add this change.

                                • Onur Gursoy 05.04.2018

                                  Hi ,

                                  This solution works fine for mousewheel but i need to same behaviour for touchscroll. When i try to touch scroll on hover grid, scrollablecontrol dont scroll. So how can i improve ScrollHelper class for touch scroll?

                                • Svetlana (DevExpress Support) 05.04.2018

                                  Hello,

                                  I've created a separate ticket on your behalf (T632619: XtraScrollableControl - How to scroll content by a touch gesture). It has been placed in our processing queue and will be answered shortly.

                                0 Solutions

                                Creation Date Importance Sort by