windowsforms-devexpress-dot-xtraeditors-dot-baselistboxcontrol-80715b83.md
Allows you to draw custom scrollbars, or highlight specific positions on the scrollbars.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Appearance")]
public event EventHandler<ScrollBarCustomDrawEventArgs> CustomDrawScroll
<DXCategory("Appearance")>
Public Event CustomDrawScroll As EventHandler(Of ScrollBarCustomDrawEventArgs)
The CustomDrawScroll event's data class is DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs.
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.
private void listBoxControl1_CustomDrawScroll(object sender, 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;
}
Private Sub listBoxControl1_CustomDrawScroll(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs) _
Handles listBoxControl1.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).
Custom scrollbar annotations are drawn even if the Handled event parameter is set to false.
private void listBoxControl1_CustomDrawScroll(object sender, ScrollBarCustomDrawEventArgs e) {
if (!e.Horizontal) {
e.HighlightPosition(0, Color.Green, Alignment.Far);
e.HighlightRegion(10, 10, Color.Blue, Alignment.Center);
}
}
Private Sub listBoxControl1_CustomDrawScroll(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.ScrollBarCustomDrawEventArgs) _
Handles listBoxControl1.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