HypernovaDesktop Components · docs
Binarymission
WinForms › Watermark Text Box › WatermarkProvider

WatermarkProvider

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.InputControls

The control that draws a WatermarkTextBox's prompt: an optional picture on the left and the prompt text beside it, centred vertically.

public sealed class WatermarkProvider : WatermarkControlProvider

Inherits from / implements: WatermarkControlProvider

Remarks

A WatermarkTextBox creates one for itself, and copies its prompt settings – WatermarkTextBox.WatermarkText, the font and the colours – onto it each time it paints, so applications rarely touch it directly.

The text is drawn by a label that takes the provider's Control.Font, Control.ForeColor and Control.BackColor. The picture, when shown, sits 4 logical pixels in from the top-left corner with a 6 logical-pixel gap before the text. Clicks on either part raise the provider's Control.MouseUp event, which is how the text box knows to start editing.

See also

Members at a glance

Constructors
WatermarkProviderInitialises a provider with no picture and the prompt text "[Type your text here...]".
Properties
ShouldRenderWatermarkImageGets or sets whether the picture is drawn to the left of the prompt text.
WatermarkImageGets or sets the picture drawn to the left of the prompt text.
WatermarkImageSizeGets or sets the size the picture is stretched to.
WatermarkTextGets or sets the prompt text.
Methods
OnSizeChangedRaises the Control.SizeChanged event and lays the picture and the text out again for the new size.

Constructors

WatermarkProvider

public WatermarkProvider()

Initialises a provider with no picture and the prompt text "[Type your text here...]".

Remarks

The text is not drawn until WatermarkText is assigned; a WatermarkTextBox assigns it when it paints.

Properties

ShouldRenderWatermarkImage

public override bool ShouldRenderWatermarkImage

Gets or sets whether the picture is drawn to the left of the prompt text.

Value
true to draw WatermarkImage; the default is false.
Remarks

Turning the picture off and on again keeps WatermarkImageSize. With no picture, the text starts 4 logical pixels from the left edge.

WatermarkImage

public override Bitmap WatermarkImage

Gets or sets the picture drawn to the left of the prompt text.

Value
The picture, or null for a text-only prompt. The default is null.
Remarks

The picture is shown only while ShouldRenderWatermarkImage is true, at WatermarkImageSize. Setting the picture here does not change WatermarkImageSize, which starts at zero; set both.

WatermarkImageSize

public override Size WatermarkImageSize

Gets or sets the size the picture is stretched to.

Value
The width and height, in pixels, applied as given. The default is Size.Empty, which leaves the picture invisible.

WatermarkText

public override string WatermarkText

Gets or sets the prompt text.

Value
The text drawn as the prompt. The default is "[Type your text here...]".

Methods

OnSizeChanged

protected override void OnSizeChanged(EventArgs e)

Raises the Control.SizeChanged event and lays the picture and the text out again for the new size.

Parameters
e
The data for the event.