WatermarkProvider
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 | |
|---|---|
WatermarkProvider | Initialises a provider with no picture and the prompt text "[Type your text here...]". |
| Properties | |
ShouldRenderWatermarkImage | Gets or sets whether the picture is drawn to the left of the prompt text. |
WatermarkImage | Gets or sets the picture drawn to the left of the prompt text. |
WatermarkImageSize | Gets or sets the size the picture is stretched to. |
WatermarkText | Gets or sets the prompt text. |
| Methods | |
OnSizeChanged | Raises the Control.SizeChanged event and lays the picture and the text out again for the
new size. |
Constructors
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
Gets or sets whether the picture is drawn to the left of the prompt text.
- Value
trueto drawWatermarkImage; the default isfalse.
Remarks
Turning the picture off and on again keeps WatermarkImageSize. With no
picture, the text starts 4 logical pixels from the left edge.
WatermarkImage
Gets or sets the picture drawn to the left of the prompt text.
- Value
- The picture, or
nullfor a text-only prompt. The default isnull.
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
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
Gets or sets the prompt text.
- Value
- The text drawn as the prompt. The default is "[Type your text here...]".
Methods
OnSizeChanged
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.