This is a migrated thread and some comments may be shown as answers.

Scroll Event not firing

14 Answers 295 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Guillaume Crétot Richert
Top achievements
Rank 1
Guillaume Crétot Richert asked on 11 Sep 2009, 06:39 PM
Hi!

The Scroll event does not seem to be raised when I scroll a RadGridView. Is this a known issue?

Thank you!

14 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 14 Sep 2009, 02:42 PM
Hi Guillaume Crétot Richert,

Scroll event is a generic event coming from the Control class. It is not used in RadGridView. You can use GridElement.VScrollBar.Scroll and GridElement.HScrollBar.Scroll events instead. Here is a sample:

this.radGridView1.GridElement.VScrollBar.Scroll += new ScrollEventHandler(VScrollBar_Scroll); 
void VScrollBar_Scroll(object sender, ScrollEventArgs e) 
    //... 

However, MS DataGridView fires this event and we will consider implementing that in a future version of RadGridView. If you need further assistance, please don't hesitate to write back.

All the best,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 14 Sep 2009, 03:35 PM
Thanks, that seems to work, although the event is not fired when the scrolling is done through the mouse wheeling. The DataGridView.Scroll event is fired, whether the scrolling occurs through clicking the scrollbar or using the wheel, so I would think that VScrollBar.Scroll should behave the same. The workaround to this problem, of course, is to handle the MouseWheel event and call the handler for the Scroll event.
0
Jack
Telerik team
answered on 15 Sep 2009, 07:25 AM
Hi Guillaume Crétot Richert,

Thank you for this additional information. We will take it into consideration when implementing the Scroll event of RadGridView.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
scottw
Top achievements
Rank 1
answered on 04 Feb 2011, 07:39 PM
Did this ever get implemented?  I have a scroll event which I have verified is firing when dragging the thumb, when clicking the arrows and when paging up and down using the scroll bar.  But when I use the wheel mouse, I get no such event.  (Same thing with Home/End and Page Up/ Page Down, though I haven't searched much on that problem yet, so for all I know you already have tech notes on that.)

For instance, after assigning the datasource, I am associating an event handler as below, but the break point on the event handler does not get reached.

            gvLibrary.DataSource = _dataSource;

            gvLibrary.TableElement.VScrollBar.Value = _vertScrollPosition;
            gvLibrary.TableElement.HScrollBar.Value = _horScrollPosition;
            gvLibrary.TableElement.MouseWheel += TableElement_MouseWheel;

Thanks,

VSmirk
0
Accepted
Jack
Telerik team
answered on 09 Feb 2011, 01:21 PM
Hello VSmirk,

Thank you for your question.

We decided that it is not necessary to change the Scroll event of RadGridView. As demonstrated in the previous posts from of thread, you can handle scroll events easily using the VScrollBar and HScrollBar elements. On the other hand, keyboard and mouse events are handled by a special behavior class. In order to handle mouse wheel events, you should override the default grid behavior. Here is a sample:
this.radGridView1.GridBehavior = new MyGridBehavior();
 
public class MyGridBehavior: BaseGridBehavior
{
    public override bool OnMouseWheel(MouseEventArgs e)
    {
        return base.OnMouseWheel(e);
    }
}

I hope this helps. If you have further need of assistance, I would be glad to provide it.

All the best, Jack
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
0
scottw
Top achievements
Rank 1
answered on 09 Feb 2011, 03:28 PM
Thank you.  GridBehavior is definitely a feature I missed in the documentation.  In this case, I ended up solving by using the TableElement.Mousewheel event and creating my own custom scrolling event from that handler.

Thanks again for your help!
0
Naseem
Top achievements
Rank 1
answered on 21 Dec 2011, 11:14 PM
Hello,

I need to implement RadGridview scrolling event however there is no TableElement and GridBehavior definition in it. The version I'm using is 2011.1.419.1040 ,

Kind Regards,
Naseem
0
Jack
Telerik team
answered on 22 Dec 2011, 12:56 PM
Hello Naseem,

Please note that there is no 2011.1.419.1040 version of RadControls for WinForms. The closest one is Q1 2011 SP1 (2011.1.11.419). Could you confirm that you are using RadControls for WinForms. If this is true, you should be able to use the code provided in this thread. 

If you are using some other Telerik product, please address your question in the corresponding forum thread. Thank you for your understanding.

Should you have any other questions, we will be glad to help.
 
Greetings,
Jack
the Telerik team

Q3’11
of RadControls for WinForms is available for download (see what's new). Get it today.
0
Naseem
Top achievements
Rank 1
answered on 22 Dec 2011, 11:58 PM
Hello Jack,

I'm Sorry,my mistake. I didn't check the thread is related to winforms . My question was related to Silverlight.

By the way thank you for your quick respond.

Best Regards,
Naseem
0
Jeff
Top achievements
Rank 1
answered on 27 Nov 2014, 08:01 PM
Hi Jack,

I'm a few years late to the party.  Is there an answer to the crippled ScrollableControl.Scroll event that works in late 2014?  The aforementioned "RadGridView.GridElement" property no longer exists.  I've even extended from RadGridView to see what I could get at, and have found nothing so far.

01.public class WhereIsMyScrollingGridView : RadGridView
02.{
03.    public WhereIsMyScrollingGridView()
04.        : base()
05.    {
06.        //this.GridBehavior.HasNoScrollingHooks();
07.        //this.GridNavigator.HasNoScrollingHooks();
08.        //this.GridViewElement.HasNoScrollingHooks();
09.        //this.TableElement.ScrollBehavior.
10.        //  ScrollServices[n].IsInterestingButUltimatelyADeadend();
11.    }
12. 
13.    /// <summary>
14.    /// Never called.  Thank you for that.
15.    /// </summary>
16.    /// <param name="se"></param>
17.    protected override void OnScroll(ScrollEventArgs se)
18.    {
19.        DisplayScrollDebug(se);
20.        base.OnScroll(se);
21.    }
22. 
23.    private void DisplayScrollDebug(ScrollEventArgs se)
24.    {
25.        string message = string.Format("{0}({1}) from {2} to {3}",
26.            se.ScrollOrientation, se.Type, se.OldValue, se.NewValue);
27.        System.Diagnostics.Debug.WriteLine(message, this.GetType().Name);
28.    }
29.}

Thank you in advance for a 2014-compatible workaround,
~Jeff

P.S. I am using UI for WinForms Q2 2014, and am not yet able to upgrade, though I will be making a case for that soon.  Regardless, it stands to reason that the GridElement property has not suddenly been reintroduced after being removed.
0
Dimitar
Telerik team
answered on 02 Dec 2014, 02:02 PM
Hi Jeff,

Thank you for contacting us.

You still need to use the same approach to handle all cases where the user scrolls. For example you can implement this in a custom grid and handle the scroll in a single function:
public class MygridView : RadGridView
{
    protected override void CreateChildItems(Telerik.WinControls.RadElement parent)
    {
        base.CreateChildItems(parent);
        this.TableElement.VScrollBar.Scroll += VScrollBar_Scroll;
        this.TableElement.HScrollBar.Scroll += HScrollBar_Scroll;
        this.GridViewElement.GridBehavior = new MyGridBehavior();
    }
 
    void HScrollBar_Scroll(object sender, ScrollEventArgs e)
    {
        this.MyScrollFunction();
    }
 
    void VScrollBar_Scroll(object sender, ScrollEventArgs e)
    {
        this.MyScrollFunction();
    }
 
    public void MyScrollFunction()
    {
        Console.WriteLine("Scroll executed");
    }
}
 
public class MyGridBehavior : BaseGridBehavior
{
    public override bool OnMouseWheel(MouseEventArgs e)
    {
        ((MygridView)this.GridControl).MyScrollFunction();
        return base.OnMouseWheel(e);
    }
}

I hope this helps.

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jeen
Top achievements
Rank 1
answered on 06 Nov 2015, 03:50 PM

Hi, everyone.

I have a problem contiguous to the one discussed in this thread. So I decided to ask for your advice here.

On my form I have a RadGridView with one "SummaryRowsBottom" containing totals for 8 columns.

The requirement goes - I cannot make the form very large because the end-user display dimensions are limited to 1024 by 768. Meanwhile the columns are numerous in the RadGridView, so when the user extracts data to the grid, only some of the columns are visible. At the bottom of the form there is a label containing a single total which is actually the sum of all the totals in the summary rows in the grid. This total of the summary row totals is calculated in the "RadGridView_GroupSummaryEvaluate()" event.

The problem is when the user scrolls the grid horizontally to see the data in the rest of the columns, the total in the label changes. I presume that calculation of the summary row totals is somehow bound to the cells visible at the current moment.

I tried to use the "RadGridView_Scroll" event to make necessary changes for the total in the label to be displayed correctly, but the event doesn't fire.

I have also tried to use the above-mentioned workaround:

"this.radGridView1.GridElement.VScrollBar.Scroll += new ScrollEventHandler(VScrollBar_Scroll); 
void VScrollBar_Scroll(object sender, ScrollEventArgs e) 

    //... 
} ".

This event fires. ​However, it causes the application to freeze for a few seconds with no eventual results visible in the label.

 

I would like to know if, by any chance, the Telerik Team by now has implemented the functionality for the RadGridView "Scroll" event. Any other workaround to prevent the label total from changing due to the scroll action will also be much appreciated.

 

Thanks in advance.

 Best regards,

Jeen.
0
Dimitar
Telerik team
answered on 09 Nov 2015, 03:15 PM
Hi Jeen,

Thank you for writing.

You are correct, the summary rows are updated when they are shown. If you want to detect when the user scrolls you should use the Scroll or MouseWheel event which are shown in my previous post. Nevertheless, in this case, it would be better to manually calculate the value for the label - not using the values from the summary rows. For example, you can use the CellValueChanged event and recalculate the value when it is fired. More information about how you can track changes in the grid is available here: Tracking changes in RadGridView.

I hope this helps.

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jeen
Top achievements
Rank 1
answered on 10 Nov 2015, 10:08 AM

Hello, Dimitar.

Thank you for advice. I will search in that direction.

 

Best regards,

Jeen.

Tags
GridView
Asked by
Guillaume Crétot Richert
Top achievements
Rank 1
Answers by
Jack
Telerik team
Guillaume Crétot Richert
Top achievements
Rank 1
scottw
Top achievements
Rank 1
Naseem
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
Dimitar
Telerik team
Jeen
Top achievements
Rank 1
Share this question
or