Skybound Rebar

Rebar.DrawBand Event

Occurs when a band needs to be drawn.

[Visual Basic]
Public Event DrawBand As DrawBandEventHandler
[C#]
public event DrawBandEventHandler DrawBand;

Event Data

The event handler receives an argument of type DrawBandEventArgs containing data related to this event. The following DrawBandEventArgs properties provide information specific to this event.

Property Description
Band Gets the RebarBand to draw.
Graphics Gets the Graphics surface to draw the band on.
Renderer Gets a renderer that can draw the band.

Remarks

The DrawBandEventArgs argument passed to a DrawBand event handler provides a Graphics object that enables you to perform drawing and other graphical operations on the surface of the rebar. You can use this event handler to create custom bands that meet the needs of your specific application.

This event is only raised if the value of the DrawMode property of the rebar control is set to OwnerDraw. Otherwise, the default drawing implementation is used.

To get the bounds of the various elements of the band, such as the size grip or the chevron button, use the RebarBandRenderer object provided by the the Renderer property. This renderer may also be used to invoke the default implementation for elements of the band that do not require customization. For more information about using renderers, see Using Renderers.

Example

The following example demonstrates how to handle the DrawBand event. In the example, the default implementation is used to draw the elements of the band other than the size grip. The size grip is drawn using horizontal lines, creating the look of the Microsoft Office XP toolbars. This example assumes that you have initialized the DrawMode property to OwnerDraw.

            
// The DrawBand event handler:
private void rebar1_DrawBand(object sender, Skybound.Rebar.DrawBandEventArgs e)
{
    // Use the default implementation for the band's image, text, and chevron:
    e.Renderer.DrawImage(e.Graphics);
    e.Renderer.DrawText(e.Graphics);
    e.Renderer.DrawChevron(e.Graphics);
    
    // Get the bounds of the size grip:
    Rectangle sizeGrip = e.Renderer.GetSizeGripRectangle();
    sizeGrip.Inflate(-2, -2);
    
    // Fill the size grip with horizontal lines:
    using (HatchBrush brush = new HatchBrush(HatchStyle.NarrowHorizontal, SystemColors.ControlDark, Color.Transparent))
        e.Graphics.FillRectangle(brush, sizeGrip);
}
            

See Also

Rebar Class | Skybound.Rebar Namespace