WinForms › Extended Text
Extended Text
.NET Framework 4.8.NET 6 / 8 / 10v3.0.1WinForms
A TextBox with a flat, coloured border that can light up under the pointer, be drawn
dotted, and blink to draw the eye to a field that needs attention.
3public types
44public members
1namespaces
Assembly
| Assembly | Binarymission.WinForms.Controls.ExtendedText.dll |
| Root namespace | Binarymission.WinForms.Controls.TextControls |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
Overview
What it is for
Use it in place of a TextBox on forms where the classic sunken 3-D edge looks out
of place, or where a field should call for attention – a required field left empty, or a value that
failed validation. All the editing, selection, clipboard and scrolling behaviour is the standard
text box's; only the frame round it is drawn by the control.
The border
- While
ExtendedStateistrue(the default), a one-pixel border is drawn inBorderColor, continuous or dotted (DrawBorder). WithExtendedStatefalsethe box keeps a classic sunken edge. - With
ShowBorderAlwaystrue(the default) the border is always drawn inBorderColor. Set it tofalsefor a hover effect: the border is drawn inBorderColorWhenControlIsNotInFocusat rest, and inBorderColorwhile the pointer is over the box or it has the focus. - When the box is disabled, the control draws the greyed text itself; in the flat
style it does so on a window background, with a border in
BorderColorWhenControlIsDisabled.
Blinking
StartToBlink() flashes the border between a colour of your choice and
BorderColor until StopBlinking is called – a quiet way to point at the
field a validation message is about.
Getting started
using System;
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.TextControls;
public class NewCustomerForm : Form
{
private readonly BinaryExtendedText emailBox;
public NewCustomerForm()
{
Text = "New customer";
ClientSize = new Size(340, 110);
emailBox = new BinaryExtendedText
{
Location = new Point(12, 12),
Width = 316,
BorderColor = Color.SteelBlue,
BorderColorWhenControlIsNotInFocus = Color.Silver,
ShowBorderAlways = false // grey at rest, blue under the pointer or with the focus
};
emailBox.TextChanged += (sender, e) => emailBox.StopBlinking();
var saveButton = new Button { Text = "Save", Location = new Point(253, 70) };
saveButton.Click += SaveButton_Click;
Controls.Add(emailBox);
Controls.Add(saveButton);
}
private void SaveButton_Click(object sender, EventArgs e)
{
if (!emailBox.Text.Contains("@"))
{
emailBox.StartToBlink(Color.Crimson, 400); // flash until the user edits the field
emailBox.Focus();
return;
}
Close();
}
}API reference
Binarymission.WinForms.Controls.TextControls
class BinaryExtendedText | A TextBox with a flat, coloured border that can light up under the pointer, be drawn dotted, and blink to draw the eye to a field that needs attention. |
class BinaryNumericExtendedText | A BinaryExtendedText for numbers - quantities, prices, percentages - that accepts only numeric input, can hold the value within a range, steps it with the arrow keys and the mouse wheel, and reads it back as a decimal. |
enum BorderState | The two ways a BinaryExtendedText can draw its border line. |