Siticone TextBox Advanced
The SiticoneTextBoxAdvanced is a powerful UserControl that wraps standard input functionality with a modern, high-performance rendering engine.
It provides smooth animated border transitions, comprehensive input validation (Email, Password, Digits), integrated image support, and a robust event system for tracking enhanced states like validation errors and read-only interactions.
Input & Validation
The control features a built-in validation engine that can automatically verify input patterns, handle password strength requirements, and restrict character entry.
| Property | Type | Description & Usage Example |
|---|---|---|
InputType |
AdvancedTextBoxInputType |
txt.InputType = AdvancedTextBoxInputType.Email;
Determines the validation logic.
Options:
• String: Normal text (default). • Digit: Allows numbers only. • Email: Validates email format. • Password: Masked input with strength checks. |
ValidationEnabled |
bool | txt.ValidationEnabled = true; Master switch to enable or disable all validation logic. |
ValidationPattern |
string | txt.ValidationPattern = "^[A-Z]{3}-\d{3}$"; Custom Regex pattern. If set, overrides default validation logic for the 'String' input type. |
ErrorColor |
Color | txt.ErrorColor = Color.Red; The color applied to the border and text when validation fails. |
IsValid |
bool | if (txt.IsValid) { Submit(); } Read-only property indicating the current validation status. |
Password Requirements
Specific properties available when InputType is set to Password.
| Property | Description |
|---|---|
MinimumPasswordLength |
Minimum characters required (Default: 8). |
RequireUppercase |
Must contain at least one uppercase letter (Default: true). |
RequireLowercase |
Must contain at least one lowercase letter (Default: true). |
RequireDigits |
Must contain at least one number (Default: true). |
RequireSpecialCharacters |
Must contain special symbols (Default: true). |
Appearance & Styling
Customize the visual presentation, including borders, shapes, and colors for different states (Hover, Focus, Idle).
| Property | Type | Description & Usage Example |
|---|---|---|
TextBoxType |
TextBoxType |
txt.TextBoxType = TextBoxType.Material;
Default: Standard box with 4 borders. Material: Only the bottom border is drawn. |
BorderColor |
Color | txt.BorderColor = Color.Silver; |
FocusBorderColor |
Color | txt.FocusBorderColor = Color.DodgerBlue; Border color when the control has focus. |
HoverBorderColor |
Color | txt.HoverBorderColor = Color.Gray; |
HoverOpacity |
float | txt.HoverOpacity = 0.8f; Opacity (0.0 - 1.0) of the border when hovering. Creates a subtle fade effect. |
BackgroundColor |
Color | txt.BackgroundColor = Color.White; |
BorderWidth |
int | txt.BorderWidth = 2; |
CornerRadius... |
int | txt.TopLeftCornerRadius = 10; Individual control for TopLeft, TopRight, BottomLeft, BottomRight radii. |
MakeRadial |
bool | txt.MakeRadial = true; Automatically rounds the ends of the textbox to be fully circular based on height. |
Text & Placeholder
| Property | Type | Description & Usage Example |
|---|---|---|
TextContent |
string | txt.TextContent = "Hello World"; The main text value. Equivalent to standard .Text property. |
TextColor |
Color | txt.TextColor = Color.Black; |
PlaceholderText |
string | txt.PlaceholderText = "Enter email..."; Text shown when the control is empty. |
PlaceholderColor |
Color | txt.PlaceholderColor = Color.Gray; |
PlaceholderFocusColor |
Color | txt.PlaceholderFocusColor = Color.Blue; Color of the placeholder text when the control has focus but is still empty. |
Multiline |
bool | txt.Multiline = true; Allows text to span multiple lines. Note: Image support is disabled in multiline mode. |
Images & Icons
The control supports displaying an icon with automatic animation transitions between states (Idle -> Hover -> Focus).
| Property | Type | Description & Usage Example |
|---|---|---|
IdleImage |
Image | txt.IdleImage = Resources.search_gray; |
HoverImage |
Image | txt.HoverImage = Resources.search_blue; |
FocusImage |
Image | txt.FocusImage = Resources.search_focus; |
ImagePosition |
ImagePosition | txt.ImagePosition = ImagePosition.Left; Left or Right alignment. |
ImageHoverOpacity |
float | txt.ImageHoverOpacity = 0.5f; Opacity level (0.1 to 0.9) used during image transitions for smooth effects. |
ReadOnly Behavior
Advanced customization for the ReadOnly state. Unlike standard controls which just gray out, you can define a specific color palette for the locked state.
| Property | Type | Description |
|---|---|---|
IsReadOnly |
bool | Toggles the read-only mode. |
ReadOnlyColors |
ReadOnlyColors |
Nested property to style the locked state.
• .BackgroundColor
• .BorderColor
• .TextColor
• .PlaceholderColor
|
Public Methods
// Forces validation logic to run immediately.
// Returns true if valid, false if errors exist.
// Also updates the visual state (ErrorColor) and ValidationErrors collection.
bool isFormValid = siticoneTextBox1.ValidateInput();
// Clears the text content, resets validation state,
// and restores the placeholder.
siticoneTextBox1.Clear();
// Helper to set BorderColor, FocusBorderColor, and HoverBorderColor
// to the same value in one call.
siticoneTextBox1.SetBorderColor(Color.Black);
Enhanced Event System
The control provides an "Enhanced" event system that delivers rich context data (Event Arguments) compared to standard WinForms events.
// Occurs when the Enter key is pressed.
// The arguments provide data on text validity, modifiers (Shift/Ctrl), and allow sound suppression.
txt.EnterKeyPressed += (s, e) =>
{
// Access properties via 'e' (EnterKeyPressedEventArgs)
if (e.Modifiers == Keys.Shift)
{
// Allow new line for Shift+Enter
e.SuppressSound = false;
return;
}
// Submit logic
SendMessage(e.Text);
// Prevent the default "Ding" sound
e.SuppressSound = true;
e.Handled = true;
};
// Provides old text, new text, validation status, and visual state
txt.TextContentChangedEnhanced += (s, e) =>
{
Console.WriteLine($"Text changed from '{e.OldText}' to '{e.NewText}'");
if (!e.IsValid)
{
// Access list of specific validation errors
var errors = e.ValidationErrors;
}
};
// Fired when validity flips (Valid -> Invalid or vice versa)
txt.ValidationChangedEnhanced += (s, e) =>
{
// Enable/Disable a submit button based on validity
btnSubmit.Enabled = e.IsValid;
if (e.HasValidationError)
{
lblStatus.Text = "Please fix the errors.";
lblStatus.ForeColor = e.ErrorColor; // Use the control's error color
}
};
// Fired when user clicks or types in a ReadOnly box
txt.ReadOnlyInteractionAttemptedEnhanced += (s, e) =>
{
MessageBox.Show($"You cannot edit this field. Action: {e.ActionAttempted}");
};
Designer Smart Tags
The control includes a comprehensive Smart Tag menu in Visual Studio for rapid configuration.
| Category | Actions |
|---|---|
Style Presets |
Apply pre-configured themes: Material Design, Modern, Flat. |
Input Types |
Quick setup for: Email Field, Password Field, Digit Field, Search Field. |
Color Themes |
One-click coloring: Light, Dark, Blue, Green, Purple, Red, Orange, Teal. |
Copy/Paste |
Copy settings from one TextBoxAdvanced and paste to another instantly. |
Detailed Usage Examples
Example 1: Secure Password Field
Configures a password field that requires complexity and provides visual feedback.
private void SetupPasswordField()
{
txtPassword.InputType = AdvancedTextBoxInputType.Password;
txtPassword.PlaceholderText = "Secure Password";
// Validation Rules
txtPassword.MinimumPasswordLength = 10;
txtPassword.RequireUppercase = true;
txtPassword.RequireDigits = true;
txtPassword.RequireSpecialCharacters = true;
// Styling
txtPassword.UseSystemPasswordChar = true; // Hides chars
txtPassword.FocusBorderColor = Color.MediumPurple;
txtPassword.ErrorColor = Color.Crimson;
// Handle changes to show realtime feedback
txtPassword.ValidationChangedEnhanced += (s, e) =>
{
if (!e.IsValid)
{
// Show all errors in a tooltip or label
lblError.Text = string.Join("\n", e.ValidationErrors);
}
};
}
Example 2: Search Bar with Icon
Creates a rounded "pill" style search bar with a magnifying glass icon.
private void SetupSearchBar()
{
txtSearch.TextBoxType = TextBoxType.Default;
txtSearch.PlaceholderText = "Search...";
// "Pill" shape
txtSearch.MakeRadial = true;
// Images for different states
txtSearch.ImagePosition = ImagePosition.Left;
txtSearch.IdleImage = Properties.Resources.search_gray;
txtSearch.FocusImage = Properties.Resources.search_active;
// Visuals
txtSearch.BackgroundColor = Color.WhiteSmoke;
txtSearch.BorderColor = Color.LightGray;
txtSearch.BorderWidth = 1;
// Disable validation for search
txtSearch.ValidationEnabled = false;
}
Example 3: Messenger Style Input (New)
Demonstrates using EnterKeyPressed to handle chat input.
It sends the message on Enter but allows a new line on Shift+Enter.
private void SetupChatBox()
{
// 1. Configure for Multiline
txtMessage.Multiline = true;
txtMessage.Height = 60;
txtMessage.PlaceholderText = "Type a message...";
txtMessage.TopLeftCornerRadius = 15;
txtMessage.TopRightCornerRadius = 15;
txtMessage.BottomLeftCornerRadius = 15;
txtMessage.BottomRightCornerRadius = 15;
// 2. Handle the Key Event
txtMessage.EnterKeyPressed += (s, e) =>
{
// If User holds Shift, we want the default behavior (New Line)
// We also ensure the sound is NOT suppressed.
if (e.Modifiers == Keys.Shift)
{
e.SuppressSound = false;
return;
}
// If just Enter is pressed, we Send the message
if (e.IsValid && e.TextLength > 0)
{
SendMessage(e.Text);
// Clear the box
txtMessage.Clear();
// Crucial: Mark handled and suppress sound to prevent "Ding"
e.Handled = true;
e.SuppressSound = true;
}
};
}