# Borders class
{: .no_toc }

The collection of border strokes drawn around a region. Each stroke is an independent [**Border**](#border-class) sub-object with its own thickness, fill, and blending behaviour, layered in source order. A single thin black outline is a one-element collection --- easiest constructed by calling [**SetSimpleBorder**](#setsimpleborder).

Accessed as `<state>.Borders`, [**CellRenderingOptions.Borders**](/tB/Packages/CustomControls/WaynesGrid/CellRenderingOptions.md#borders), and the slider's `<sliderState>.BackgroundBorders` / `BlockBorders`. The array of [**Border**](#border-class) sub-objects on a [**TextRendering**](/tB/Packages/CustomControls/Styles/TextRendering.md)'s **Outlines** member uses the same element type.

```tb check_build
btnGo.NormalState.Borders.SetSimpleBorder StrokeSize:=1, ColorRGB:=vbBlack
```

An element already in the array is reached through [**Elements**](#elements) and restyled in place:

```tb check_build
btnGo.NormalState.Borders.SetSimpleBorder StrokeSize:=4, ColorRGB:=vbBlack
btnGo.NormalState.Borders.Elements(0).BlendWithBackgroundFill = True
```

Layered borders --- multiple [**Border**](#border-class) instances stroked in order --- are assigned to the [**Elements**](#elements) array directly. Each element can have its own [**StrokeSize**](#strokesize) and its own [**Fill**](/tB/Packages/CustomControls/Styles/Fill.md), so a thin black outline can sit on top of a wide coloured band, or three bands of different colours can stack into a "shadow":

```tb check_build project=cc-private
Dim elems(0 To 2) As CustomControlsPackage.Border
Set elems(0) = New CustomControlsPackage.Border
elems(0).StrokeSize = 4
elems(0).Fill.ColorPoints.SetSolidColor vbBlack
Set elems(1) = New CustomControlsPackage.Border
elems(1).StrokeSize = 7
elems(1).Fill.ColorPoints.SetSolidColor &H99CCFF       ' light orange band
Set elems(2) = New CustomControlsPackage.Border
elems(2).StrokeSize = 4
elems(2).Fill.ColorPoints.SetSolidColor &H4D7AB4       ' brown
btnGo.NormalState.Borders.Elements = elems
```

> [!IMPORTANT]
>
> [**Border**](#border-class) is a **Private** component of the package, so naming it takes
> two things: the **CustomControlsPackage** library symbol prefixed with an asterisk in
> *Project Settings* --- the control package, not the **CustomControls** DESIGNER library
> listed beside it --- and the package qualifier used above. See [Exposing a library's private
> symbols](/Features/Packages/Library-Symbols.md#exposing-a-librarys-private-symbols)
> for the setting and where to find it. Without the asterisk neither `Border` nor
> `CustomControlsPackage.Border` resolves; with it, only the qualified form does.
>
> Nothing else on this page needs it. [**SetSimpleBorder**](#setsimpleborder) and restyling
> an element already in [**Elements**](#elements) work in an ordinary project.

A single [**Border**](#border-class) can also display a gradient instead of a solid colour --- assign a multi-stop [**Fill**](/tB/Packages/CustomControls/Styles/Fill.md) to its [**Fill**](#fill) member. Set [**BlendWithBackgroundFill**](#blendwithbackgroundfill) to **True** on a translucent border to make it tint with the control's own **BackgroundFill** rather than with whatever lies under the control.

A button in its default look, which has no border, and with each of the three samples above:

![Four blue buttons: with no border; with a thin black border; with a thick black border; and with three borders inside each other, black outside, light orange in the middle and brown inside](/Reference/Built-In/CustomControls/Styles/Images/Borders.png){:width="733" height="197"}

* TOC
{:toc}

## Properties

### Elements
{: .no_toc }

The array of [**Border**](#border-class) sub-objects, drawn in order from index 0 outward. Read-write; assigning it needs a `Border()` array, which the project can only declare when the package is imported with an asterisk --- see the note at the top of this page. Otherwise the array is populated through [**SetSimpleBorder**](#setsimpleborder) or [**SetSimpleBorderRGBA**](#setsimpleborderrgba), and the elements already in it are adjusted in place.

## Methods

### SetSimpleBorder
{: .no_toc }

Replaces the [**Elements**](#elements) array with a single border stroke of the given thickness and fully-opaque colour.

Syntax: *object*.**SetSimpleBorder** *StrokeSize*, *ColorRGB*

*StrokeSize*
: *required* A **Long** giving the stroke thickness in pixels.

*ColorRGB*
: *required* A **Long** RGB colour for the stroke fill.

### SetSimpleBorderRGBA
{: .no_toc }

Replaces the [**Elements**](#elements) array with a single border stroke whose alpha is taken from the supplied [**ColorRGBA**](/tB/Packages/CustomControls/Enumerations/ColorRGBA.md) rather than forced opaque. Useful for transparent borders that are present only as visual padding (the slider uses a fully transparent border on the **BlockBorders** to indent the block inside the background).

Syntax: *object*.**SetSimpleBorderRGBA** *StrokeSize*, *ColorRGBA*

*StrokeSize*
: *required* A **Long** giving the stroke thickness in pixels.

*ColorRGBA*
: *required* A [**ColorRGBA**](/tB/Packages/CustomControls/Enumerations/ColorRGBA.md) value for the stroke fill.

## Events

### OnChanged
{: .no_toc }

Raised when the [**Elements**](#elements) array is reassigned, or when any single [**Border**](#border-class) element raises its own **OnChanged**.

## Border class

A single border stroke. Elements of [**Borders.Elements**](#elements), and also of [**TextRendering.Outlines**](/tB/Packages/CustomControls/Styles/TextRendering.md#outlines).

### BlendWithBackgroundFill
{: .no_toc }

When **True**, the border's colour alpha-blends with the control's **BackgroundFill** rather than with whatever is painted underneath the control. Lets a translucent border colour use the background tint instead of the form's. **Boolean**. Default: **False**.

### Fill
{: .no_toc }

The [**Fill**](/tB/Packages/CustomControls/Styles/Fill.md) that supplies the colour or gradient used to stroke the border. Newly-constructed [**Border**](#border-class) objects pre-set this to a solid black fill.

### StrokeSize
{: .no_toc }

The stroke thickness in pixels. [**PixelCount**](/tB/Packages/CustomControls/Enumerations/PixelCount.md). Default: 1.

### New
{: .no_toc }

Constructs a [**Border**](#border-class) with a default solid-black [**Fill**](#fill).

Syntax: **New CustomControlsPackage.Border**

The package qualifier is required, and so is importing the reference with an asterisk --- see the note at the top of this page.

### OnChanged
{: .no_toc }

Raised when [**StrokeSize**](#strokesize), [**Fill**](#fill), or [**BlendWithBackgroundFill**](#blendwithbackgroundfill) is assigned, or when the contained [**Fill**](#fill) raises its own **OnChanged**.
