Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Text Box

Siticone Text Box

The SiticoneTextBox is a fully custom-drawn input control that replaces the standard Windows Forms TextBox. It offers a premium user experience with anti-aliased text rendering, smooth animations for borders and placeholders, built-in validation logic, and extensive styling options including gradients and drop shadows.

Text & Input Handling

Properties for managing text content, security masking, and input restrictions.

Property Type Description & Usage Example
Text string txtInput.Text = "Sample Text"; The current text content. Changes trigger the TextUpdated event.
PlaceholderText string txtInput.PlaceholderText = "Enter your email..."; Text displayed when the control is empty. Includes a smooth fade-in/out animation (20ms interval) when focus changes.
UseSystemPasswordChar bool txtPass.UseSystemPasswordChar = true; Masks characters for sensitive input using the system password character.
PasswordChar char txtPass.PasswordChar = '●'; Custom character used for masking if UseSystemPasswordChar is true.
MaxLength int txtInput.MaxLength = 50; Limits the number of characters that can be entered.
TextCaseMode TextCase txtCode.TextCaseMode = TextCase.Upper; Automatically transforms input. Options: Normal, Upper, Lower.

Visual Styling

Extensive customization for backgrounds, gradients, and text appearance.

Property Type Description & Usage Example
SolidFillColor Color txtInput.SolidFillColor = Color.White; Background color when UseFillGradient is false.
UseFillGradient bool txtInput.UseFillGradient = true; Enables gradient background rendering.
FillColor1 / FillColor2 Color txtInput.FillColor1 = Color.AliceBlue; Start and end colors for the background gradient.
ForeColor Color txtInput.ForeColor = Color.Black;
PlaceholderColor Color txtInput.PlaceholderColor = Color.Gray;

Borders & Animation

Advanced border styling with states for Normal, Hover, and Focus, plus animations.

Property Type Description & Usage Example
ShowBorder bool txtInput.ShowBorder = true;
BorderSize int txtInput.BorderSize = 2;
SolidBorderColor Color txtInput.SolidBorderColor = Color.Silver;
SolidBorderFocusColor Color txtInput.SolidBorderFocusColor = Color.DodgerBlue; Border color when the control has focus. Animates smoothly.
SolidBorderHoverColor Color txtInput.SolidBorderHoverColor = Color.Gray; Border color on mouse hover. Animates smoothly.
CornerRadius... int txtInput.CornerRadiusTopLeft = 10; Individual control for all 4 corners (TopLeft, TopRight, BottomLeft, BottomRight).

Shadows & Effects

Visual effects to add depth and feedback, including blinking shadows.

Property Type Description & Usage Example
EnableDropShadow bool txtInput.EnableDropShadow = true; Adds a drop shadow around the control. Automatically adjusts padding.
ShadowColor Color txtInput.ShadowColor = Color.FromArgb(50, 0, 0, 0);
ShadowBlur int txtInput.ShadowBlur = 10; Controls the spread/softness of the shadow.
BlinkShadow bool txtInput.BlinkShadow = true; Causes the shadow to pulse/blink. Useful for validation errors.
BlinkCount int txtInput.BlinkCount = 3; Number of times to blink if ContinuousBlink is false.

Validation System

Built-in logic to validate input and provide feedback.

Property Type Description & Usage Example
ValidationFunction Func<string, bool> txt.ValidationFunction = val => val.Length > 3; A delegate that returns true if input is valid. Triggers validation on text change.
ValidationErrorMessage string txt.ValidationErrorMessage = "Too short!";
IsValid bool if (txt.IsValid) { ... } Read-only. Returns the result of the last validation check.

Public Methods

SetupAs... Helpers
// Quickly configure the textbox for common scenarios
txtInput.SetupAsPasswordField(); // Sets masking char, placeholder
txtInput.SetupAsEmailField();    // Sets placeholder text
txtInput.SetupAsNumericField();  // Sets placeholder for numbers
txtInput.SetupAsSearchField();   // Rounded corners, specific styling
Clear() & SelectAll()
// Clears the text and resets selection/cursor.
txtInput.Clear();

// Selects all text within the control.
txtInput.SelectAll();

Events

TextUpdated
// Fired when text changes. Provides Previous and Current values.
txtInput.TextUpdated += (sender, e) => 
{
                Console.WriteLine($"Changed from {e.PreviousText} to {e.CurrentText}");
};
Validated
// Fired after validation runs. Useful for showing UI feedback.
txtInput.Validated += (sender, e) => 
{
                if (!e.IsValid)
    {
                // Make the shadow blink to alert the user
        txtInput.BlinkShadow = true;
        errorLabel.Text = e.ErrorMessage;
    }
                else
    {
        txtInput.BlinkShadow = false;
        errorLabel.Text = "";
    }
};

EnterKeyPressed

Occurs when the user presses the Enter key. This event suppresses the standard Windows "ding" sound and provides a snapshot of the control's state via EnterKeyPressedEventArgs. This allows you to handle submission logic (like sending a message or calculating a value) without needing to manually query the control properties or handle standard KeyDown events.

Event Data: EnterKeyPressedEventArgs

Property Type Description
Text string The exact text content of the control at the moment Enter was pressed.
IsValid bool Indicates if the text passed the user-defined ValidationFunction.
IsNumeric bool Helper property. Returns true if the text can be successfully parsed as a double.
IsEmptyOrPlaceholder bool Returns true if the textbox is actually empty or if it is currently displaying the placeholder text.
Enter Key Logic Example
txtInput.EnterKeyPressed += (sender, e) => 
{
                // 1. Basic Safety: Ignore if empty
                if (e.IsEmptyOrPlaceholder) return;

                // 2. Validation Check: Ensure data is valid before processing
                if (!e.IsValid) 
    {
                MessageBox.Show("Please fix input errors before submitting.");
                return;
    }

                // 3. Contextual Processing based on data type
                if (e.IsNumeric)
    {
                // It is safe to parse because IsNumeric returned true
                double amount = double.Parse(e.Text);
                ProcessPayment(amount);
    }
                else
    {
                // Handle as a standard command or message
                SendMessage(e.Text);
    }

                // 4. Reset the control for next input
                var box = sender as SiticoneTextBox;
    box.Clear();
};

Designer Support

The control includes a comprehensive Smart Tag panel.

Category Features
Theme Presets Apply styles instantly: Light, Dark, Primary Accent, Flat, Material.
Field Configuration One-click setup for Password, Email, Numeric, or Search fields via the SetupAs... methods.
Quick Actions Toggle Gradient, Shadow, Rounded/Straight Corners directly.
Utilities Copy/Paste Settings: Transfer styles between controls easily via internal clipboard.

Detailed Examples

Example 1: Login Form with Validation & Feedback

A username and password setup that uses validation functions and visual feedback (shadow blinking) on error.

C# - Login Setup
public void SetupLogin()
{
                // 1. Username Configuration
    txtUsername.PlaceholderText = "Username";
    txtUsername.ValidationErrorMessage = "Username too short";
    
                // Define validation logic
    txtUsername.ValidationFunction = (val) => !string.IsNullOrWhiteSpace(val) && val.Length >= 3;

                // 2. Password Configuration (using helper)
    txtPassword.SetupAsPasswordField();
    txtPassword.ValidationErrorMessage = "Password must be 8+ chars";
    txtPassword.ValidationFunction = (val) => val.Length >= 8;

                // 3. Hook up Validation Feedback
                void OnValidated(object sender, SiticoneTextBox.ValidationEventArgs e)
    {
                var box = sender as SiticoneTextBox;
                if (!e.IsValid)
        {
                // Error state: Red border + Blinking Shadow
            box.SolidBorderColor = Color.Red;
            box.ShadowColor = Color.Red;
            box.BlinkShadow = true;
        }
                else
        {
                // Valid state: Green border + Stop Blinking
            box.SolidBorderColor = Color.Green;
            box.BlinkShadow = false;
        }
    }

    txtUsername.Validated += OnValidated;
    txtPassword.Validated += OnValidated;
}

Example 2: Modern Search Bar

A rounded search field with auto-complete suggestions and shadow depth.

C# - Search Bar
public void SetupSearchBar()
{
                // Use helper to set basic search properties
    txtSearch.SetupAsSearchField();

                // Custom Visuals
    txtSearch.CornerRadiusTopLeft = 20;
    txtSearch.CornerRadiusTopRight = 20;
    txtSearch.CornerRadiusBottomLeft = 20;
    txtSearch.CornerRadiusBottomRight = 20;

                // Drop Shadow
    txtSearch.EnableDropShadow = true;
    txtSearch.ShadowColor = Color.FromArgb(40, 0, 0, 0);
    txtSearch.ShadowBlur = 15;
    
                // Auto-Complete Configuration
    txtSearch.AutoCompleteMode = AutoCompleteMode.Suggest;
    txtSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;
    txtSearch.AutoCompleteCustomSource.AddRange(new string[] { 
                "Dashboard", "Settings", "Profile", "Reports" 
    });
}

Example 3: Read-Only Display with System Theme

A field that adapts to the OS theme and provides feedback when clicked (shake/beep).

C# - Read Only Theme
public void SetupDisplayField()
{
    txtSystemID.IsReadOnly = true;
    txtSystemID.Text = "SYS-884-XJ";
    
                // Enable System Theme Tracking
    txtSystemID.TrackSystemTheme = true;
    txtSystemID.SystemThemeChanged += (s, e) => 
    {
                if (e.Theme == SystemTheme.Dark)
        {
            txtSystemID.SolidFillColor = Color.FromArgb(45, 45, 45);
            txtSystemID.ForeColor = Color.White;
        }
                else
        {
            txtSystemID.SolidFillColor = Color.WhiteSmoke;
            txtSystemID.ForeColor = Color.Black;
        }
    };
    
                // User Feedback for ReadOnly interaction
    txtSystemID.CanBeep = true;     // Beep on typing attempt
    txtSystemID.CanShake = true;    // Shake on typing attempt
}