From Xojo Documentation


DesktopListBox.PaintDisclosureWidget(g As Graphics, row As Integer, ByRef x As Integer, ByRef y As Integer, ByRef width As Integer, ByRef height As Integer) As Boolean

New in 2021r3

Supported for all project types and targets.

Invoked for hierarchical ListBoxes when the framework needs to draw the disclosure triangle for a folder row. This is invoked after PaintCellBackground and before PaintCellText.


The left, top, width and height parameters:

  • Default to the coordinates for drawing the built-in widget
  • These coordinates are also used for hit testing to determine if a mousedown should toggle the row's expanded state.
  • Are ByRef so the user can specify the location of the rectangle used for hit testing when drawing their own widget, if for instance the hit area is smaller than the drawn widget.
  • Setting width or height to zero will completely hide the triangle and no hit testing will be done.
  • Returning False causes the framework widget to be drawn.
  • Returning True prevents the framework from drawing its own disclosure widget, signaling that the event has performed all of the necessary drawing.
  • Changing the Width parameter and returning True will offset the graphic object that is provided in the following PaintCellText event by the same offset. i.e. if the supplied Width is 10, but the code changes it to 5 the graphic object in the PaintCellText event would be offset by 5 pixels to the left.

Sample Code

This code draws a custom triangle in either blue or green to indicate if a row is expanded.

If Me.RowExpandedAt(row) Then
Var p As New GraphicsPath
p.MoveToPoint(1, 1) // Start location
p.AddLineToPoint(10, 1)
p.AddLineToPoint(5, g.Height)

g.DrawingColor = Color.Green
g.FillPath(p, True)
Var p As New GraphicsPath
p.MoveToPoint(1, 1) // Start location
p.AddLineToPoint(10, g.Height / 2)
p.AddLineToPoint(1, g.Height)

g.DrawingColor = Color.Blue
g.FillPath(p, True)
End If

Return True