Horizontal and vertical scrollbar events for WinForms DataGrid.
WinForms DataGrid (SfDataGrid) provides specific events to handle scrolling actions, which can be useful for customizing the behavior of the DataGrid
when data is being navigated. The Scroll and ValueChanged events will be raised when the user scrolls horizontally or vertically in DataGrid
.
Scroll
This event will be raised while scrolling the DataGrid
by dragging the scrollbar thumb or clicking on the scrollbar arrows.
//Event subscription
this.sfDataGrid.TableControl.HorizontalScroll.Scroll += OnScroll;
this.sfDataGrid.TableControl.VerticalScroll.Scroll += OnScroll;
//Event customization
private void OnScroll(object sender, ScrollEventArgs e)
{
// Handle the horizontal or vertical scroll event
}
ValueChanged
This event will be raised when the scrollbar values are changed. This can happen when the user scrolls the DataGrid
or when the scrollbar values are programmatically adjusted.
//Event subscription
this.sfDataGrid.TableControl.HorizontalScroll.ValueChanged += OnValueChanged;
this.sfDataGrid.TableControl.VerticalScroll.ValueChanged += OnValueChanged;
//Event customization
private void OnValueChanged(object sender, EventArgs e)
{
// Handle the horizontal or vertical value change
}
Take a moment to peruse the WinForms DataGrid - Getting Started documentation, where you can find about getting started with code examples.
Conclusion
I hope you enjoyed learning about horizontal and vertical scrollbar events for WinForms DataGrid.
You can refer to our WinForms DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms DataGrid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!