Back to Devexpress

TreeList.CustomDrawScroll Event

windowsforms-devexpress-dot-xtratreelist-dot-treelist-06c1025c.md

latest3.8 KB
Original Source

TreeList.CustomDrawScroll Event

Allows you to draw custom scrollbars, or highlight specific positions on the scrollbars.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

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

Event Data

The CustomDrawScroll event's data class is DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs.

Remarks

The CustomDrawScroll event allows you to draw custom scrollbars. The DefaultDraw method draws the default scrollbar. The Handled event argument must be set to true for the event handler to be in effect. The code below draws a custom thumb.

csharp
private void treeList1_CustomDrawScroll(object sender, DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs e) {
    e.DefaultDraw();
    e.Cache.FillRectangle(e.Cache.GetSolidBrush(Color.White), e.ThumbBounds);
    e.Cache.DrawRectangle(e.Cache.GetPen(Color.Black), e.ThumbBounds);
    e.Handled = true;
}
vb
Private Sub treeList1_CustomDrawScroll(sender As Object, e As DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs) _
    Handles treeList1.CustomDrawScroll
    e.DefaultDraw()
    e.Cache.FillRectangle(e.Cache.GetSolidBrush(Color.White), e.ThumbBounds)
    e.Cache.DrawRectangle(e.Cache.GetPen(Color.Black), e.ThumbBounds)
    e.Handled = True
End Sub

The following methods allow you to highlight specific positions on the scrollbars (draw custom scrollbar annotations).

  • HighlightPosition —draws a scrollbar annotation at the specified position (see ScrollBarBase.Value);
  • HighlightRegion —draws a scrollbar annotation at the specified positions;
  • ResetHighight —clears the scrollbar annotations created using the two previous methods;

Custom scrollbar annotations are drawn even if the Handled event parameter is set to false.

csharp
using DevExpress.XtraEditors;

private void treeList1_CustomDrawScroll(object sender, DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs e) {
    if (!e.Horizontal) {
        e.HighlightPosition(0, Color.Green, Alignment.Far);
        e.HighlightRegion(10, 10, Color.Blue, Alignment.Center);
    }
}
vb
Imports DevExpress.XtraEditors

Private Sub treeList1_CustomDrawScroll(sender As Object, e As DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs) _
    Handles treeList1.CustomDrawScroll
    If Not e.Horizontal Then
        e.HighlightPosition(0, Color.Green, Alignment.Far)
        e.HighlightRegion(10, 10, Color.Blue, Alignment.Center)
    End If
End Sub

See Also

Scrollbar Annotations

CustomScrollAnnotation

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace