Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Phone Number Box

Siticone Phone Number Box

The SiticonePhoneNumberBox is a specialized input control designed for collecting phone numbers. It features automatic country detection based on country code, intelligent formatting, validation against country-specific patterns, and a visual flag indicator to enhance the user experience.

Country & Formatting

Configure how the control handles different country standards and number formats.

Property Type Description
SelectedCountry Country Sets the active country profile (e.g., UnitedStates, UnitedKingdom). This updates the placeholder, validation rules, and country code prefix automatically.
ShowCountryFlag bool Displays the national flag icon inside the input field. The flag updates automatically based on the entered country code or `SelectedCountry`.
PhoneFormat Enum Determines the display style:
  • International: +1 (555) 123-4567
  • National: (555) 123-4567
  • Basic: 15551234567
AutoFormatting bool If true, the control automatically applies spaces, hyphens, and parentheses as the user types to match the country's standard format.
RequireCountryCode bool Enforces that the input must start with a valid country code (e.g., +1, +44).

Appearance & Styling

Customize the visual presentation, including borders, shadows, and cursor styles.

Property Type Description
EnableDropShadow bool Adds a soft shadow effect around the control.
ShadowColor Color The color of the drop shadow.
ShadowBlur int The blur radius of the shadow.
CornerRadius int Radius for rounded corners on the control border.
BorderColor1/2 Color Start and end colors for gradient borders.
UseBorderGradient bool Enables gradient rendering for the border.

Validation & Security

Ensure data integrity with built-in validation features.

Property Type Description
ValidationFunction Func<string, bool> Custom logic to validate the input. The control calls this function on text change.
ValidationErrorMessage string The message to display (or store) when validation fails.
IsValid bool Read-only property indicating current validation status.
IsReadOnly bool Locks the control against editing.
UseSystemPasswordChar bool Masks input characters (useful for sensitive PINs sent via SMS).

Events

Respond to user interactions and state changes.

Validated Event
// Fired after the internal or custom validation logic runs.
phoneBox.Validated += (s, e) => 
{
                if (!e.IsValid)
    {
        lblError.Text = e.ErrorMessage;
        lblError.Visible = true;
        btnSubmit.Enabled = false;
    }
                else
    {
        lblError.Visible = false;
        btnSubmit.Enabled = true;
    }
};
TextUpdated Event
// Fired when the text content changes.
phoneBox.TextUpdated += (s, e) => 
{
                Console.WriteLine($"Text changed from '{e.OldText}' to '{e.NewText}'");
    
                // Auto-detect country if user pastes a number with + code
                if (e.NewText.StartsWith("+44"))
    {
        phoneBox.SelectedCountry = Country.UnitedKingdom;
    }
};

Designer Support

The control includes a comprehensive Smart Tag menu in Visual Studio for rapid configuration.

Category Features
Themes One-click application of 15+ presets (Light, Dark, Material Blue, Neon, etc.).
Appearance Quick toggles for Border Size, Corner Radius, Text Align, and Shadow.
Behavior Settings for Auto-Formatting, Read-Only mode, and Feedback (Shake/Beep).
Settings Copy/Paste configuration between controls.

Usage Examples

Example 1: US Phone Number Input

Standard setup for collecting US phone numbers with auto-formatting.

C# - US Format
private void SetupUSPhone()
{
                // Configure for United States
    phoneBox.SelectedCountry = Country.UnitedStates;
    
                // Enable automatic formatting (e.g. types 1234567890 -> (123) 456-7890)
    phoneBox.AutoFormatting = true;
    phoneBox.PhoneFormat = SiticonePhoneNumberBox.PhoneNumberFormat.National;
    
                // Visuals
    phoneBox.ShowCountryFlag = true;
    phoneBox.PlaceholderText = "(555) 555-5555";
}

Example 2: International Input with Validation

Setup for accepting international numbers, requiring the country code.

C# - International
private void SetupInternationalInput()
{
    phoneBox.RequireCountryCode = true;
    phoneBox.PhoneFormat = SiticonePhoneNumberBox.PhoneNumberFormat.International;
    phoneBox.ShowCountryFlag = true;
    
                // Custom validation logic
    phoneBox.ValidationFunction = (text) => 
    {
                // Simple check: must start with + and have at least 10 digits
                return text.StartsWith("+") && text.Where(char.IsDigit).Count() >= 10;
    };
    phoneBox.ValidationErrorMessage = "Please enter a valid international number starting with +";
}

Example 3: Visual Theming

Applying a modern "Material Design" look programmatically.

C# - Material Theme
private void ApplyMaterialStyle()
{
                // Apply colors manually or use the designer presets
    phoneBox.SolidFillColor = Color.FromArgb(225, 245, 254);
    phoneBox.SolidBorderColor = Color.FromArgb(33, 150, 243);
    phoneBox.SolidBorderFocusColor = Color.FromArgb(30, 136, 229);
    
                // Enable shadow for depth
    phoneBox.EnableDropShadow = true;
    phoneBox.ShadowColor = Color.FromArgb(20, 0, 0, 0);
    phoneBox.ShadowBlur = 10;
    
                // Adjust layout
    phoneBox.TextAlign = TextAlignment.Left;
    phoneBox.CornerRadiusTopLeft = 4;
    phoneBox.CornerRadiusTopRight = 4;
    phoneBox.CornerRadiusBottomLeft = 4;
    phoneBox.CornerRadiusBottomRight = 4;
}