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
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.
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.
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
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
Thanks again for your help!
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
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.
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
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.
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.
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.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
Hello, Dimitar.
Thank you for advice. I will search in that direction.
Best regards,
Jeen.