Back to Devexpress

GridView.CustomScrollAnnotation Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-7c8e25a4.md

latest3.5 KB
Original Source

GridView.CustomScrollAnnotation Event

Allows you to specify custom annotations.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event EventHandler<GridCustomScrollAnnotationsEventArgs> CustomScrollAnnotation
vb
<DXCategory("Events")>
Public Event CustomScrollAnnotation As EventHandler(Of GridCustomScrollAnnotationsEventArgs)

Event Data

The CustomScrollAnnotation event's data class is DevExpress.XtraGrid.Views.Grid.GridCustomScrollAnnotationsEventArgs.

Remarks

The CustomScrollAnnotation event allows you to provide data about required custom annotations. Data is represented by the GridScrollAnnotationInfo type that exposes the following properties:

  • RowHandle — handle of the required row (see Row handles in the Rows topic);
  • Color — color of the mark on the scrollbar.

When handling the CustomScrollAnnotation event, explicitly initialize the e.Annotations collection, create data objects, and add them to the collection.

csharp
using using DevExpress.XtraGrid.Views.Grid;

void OnCustomScrollAnnotation(object sender, GridCustomScrollAnnotationsEventArgs e) {
    e.Annotations = new List<GridScrollAnnotationInfo>();
    GridScrollAnnotationInfo info = new GridScrollAnnotationInfo() { RowHandle = 74, Color = Color.Red };
    e.Annotations.Add(info);
}
vb
Imports using DevExpress.XtraGrid.Views.Grid

Private Sub OnCustomScrollAnnotation(ByVal sender As Object, ByVal e As GridCustomScrollAnnotationsEventArgs)
    e.Annotations = New List(Of GridScrollAnnotationInfo)()
    Dim info As New GridScrollAnnotationInfo() With {.RowHandle = 74, .Color = Color.Red}
    e.Annotations.Add(info)
End Sub

You can also use the e.SetAnnotations method to set annotations for a row array.

csharp
void OnCustomScrollAnnotation(object sender, GridCustomScrollAnnotationsEventArgs e) {
    int[] rowHandles = new int[] { 5, 17, 74 };
    e.SetAnnotations(Color.Red, rowHandles);
}
vb
Private Sub OnCustomScrollAnnotation(ByVal sender As Object, ByVal e As GridCustomScrollAnnotationsEventArgs) Handles gridView.CustomScrollAnnotation
    Dim rowHandles() As Integer = {5, 17, 74}
    e.SetAnnotations(Color.Red, rowHandles)
End Sub

Use the RefreshScrollAnnotations method to force the grid control to update/redraw scrollbar annotations.

See Also

Scrollbar Annotations

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace