syncfusion-winforms-textbox

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Implementing TextBoxes (TextBoxExt)

实现文本框(TextBoxExt)

An enhanced textbox control for Windows Forms that provides custom border styling, Office themes, multiline text support, character casing, overflow indicators, and complete appearance customization.
一款适用于Windows Forms的增强型文本框控件,提供自定义边框样式、Office主题、多行文本支持、字符大小写转换、溢出指示器和完整的外观自定义能力。

When to Use This Skill

何时使用本技能

Use this skill when you need to:
  • Enhanced TextBox: Replace standard TextBox with styled, theme-enabled alternatives
  • Custom Borders: Apply custom border colors, 3D styles, and border side configurations
  • Office Themes: Match textbox appearance to Office 2016/2019 or Metro application themes
  • Multiline Text: Display multiline text with word wrap, scrollbars, and overflow indicators
  • Text Formatting: Control character casing (uppercase/lowercase), text alignment, and RTL layouts
  • Readonly Displays: Create styled readonly text fields for labels or non-editable displays
  • Overflow Tooltips: Show tooltips when text exceeds textbox boundaries
  • Size Constraints: Enforce minimum or maximum textbox dimensions
当你需要实现以下需求时可使用本技能:
  • 增强型文本框:用支持主题的样式化方案替代标准TextBox控件
  • 自定义边框:应用自定义边框颜色、3D样式和边框侧边配置
  • Office主题:让文本框外观匹配Office 2016/2019或Metro应用主题
  • 多行文本:展示带自动换行、滚动条和溢出指示器的多行文本
  • 文本格式化:控制字符大小写(大写/小写)、文本对齐和RTL布局
  • 只读展示:创建样式化的只读文本字段,用于标签或不可编辑展示场景
  • 溢出提示:当文本超出文本框边界时展示提示框
  • 尺寸约束:强制设置文本框的最小或最大尺寸

Component Overview

组件概述

The TextBoxExt is an advanced textbox control derived from the standard TextBox that provides:
  • Custom border colors and 3D border styles
  • Eight built-in visual themes (Office2016, Office2019, Metro, Office2007, Office2010, Default)
  • Theme assembly integration with SkinManager
  • Multiline text with word wrap and configurable scrollbars
  • Character casing transformation (Upper, Lower, Normal)
  • Text alignment (Left, Center, Right)
  • Right-to-left layout support for international applications
  • Overflow indicators with customizable tooltips
  • Size constraints (MaximumSize/MinimumSize)
  • ReadOnly mode with active drawing when disabled
  • Twelve property-changed events for customization
Key Capabilities:
  • BorderColor
    and
    BorderStyle
    for custom borders
  • Style
    property for selecting visual themes
  • ThemeName
    property for runtime theme switching
  • CharacterCasing
    for automatic case transformation
  • ShowOverflowIndicator
    for text overflow detection
  • MaxLength
    for input length restrictions
  • DrawActiveWhenDisabled
    for active appearance when disabled
TextBoxExt是衍生自标准TextBox的高级文本框控件,提供以下能力:
  • 自定义边框颜色和3D边框样式
  • 8种内置视觉主题(Office2016、Office2019、Metro、Office2007、Office2010、默认)
  • 与SkinManager的主题程序集集成
  • 带自动换行和可配置滚动条的多行文本支持
  • 字符大小写转换(大写、小写、正常)
  • 文本对齐(左对齐、居中、右对齐)
  • 面向国际化应用的从右到左布局支持
  • 带可自定义提示框的溢出指示器
  • 尺寸约束(MaximumSize/MinimumSize)
  • 禁用状态下仍保持激活样式绘制的只读模式
  • 12个用于自定义的属性变更事件
核心能力:
  • 用于自定义边框的
    BorderColor
    BorderStyle
    属性
  • 用于选择视觉主题的
    Style
    属性
  • 用于运行时主题切换的
    ThemeName
    属性
  • 用于自动大小写转换的
    CharacterCasing
    属性
  • 用于文本溢出检测的
    ShowOverflowIndicator
    属性
  • 用于输入长度限制的
    MaxLength
    属性
  • 用于禁用状态下保持激活外观的
    DrawActiveWhenDisabled
    属性

Documentation and Navigation Guide

文档与导航指南

Getting Started

入门指南

📄 Read: references/getting-started.md
When to read: Starting new implementation, setting up dependencies, first-time usage, basic textbox creation
Topics covered:
  • Assembly deployment (Syncfusion.Shared.Base.dll)
  • NuGet package installation (Syncfusion.Shared.WinForms)
  • Namespace requirements (Syncfusion.Windows.Forms.Tools)
  • Adding TextBoxExt via designer (drag-and-drop)
  • Adding TextBoxExt programmatically
  • Basic TextBoxExt instantiation and configuration
  • Size configuration (MaximumSize/MinimumSize)
  • Multiline text setup with word wrap and scrollbars
  • Initial text display

📄 阅读: references/getting-started.md
适用场景: 启动新的实现、配置依赖、首次使用、基础文本框创建
涵盖内容:
  • 程序集部署(Syncfusion.Shared.Base.dll)
  • NuGet包安装(Syncfusion.Shared.WinForms)
  • 命名空间要求(Syncfusion.Windows.Forms.Tools)
  • 通过设计器添加TextBoxExt(拖拽方式)
  • 以编程方式添加TextBoxExt
  • 基础TextBoxExt实例化与配置
  • 尺寸配置(MaximumSize/MinimumSize)
  • 带自动换行和滚动条的多行文本设置
  • 初始文本展示

Text Configuration

文本配置

📄 Read: references/text-configuration.md
When to read: Configuring text properties, multiline text, character casing, alignment, overflow indicators, RTL support
Topics covered:
  • Text and SelectedText properties
  • CharacterCasing (Upper, Lower, Normal case transformation)
  • TextAlign (Left, Center, Right alignment)
  • RightToLeft layout for Arabic/Hebrew applications
  • DrawActiveWhenDisabled (active appearance when disabled)
  • Multiline text configuration
  • WordWrap property for line wrapping
  • ScrollBars (Horizontal, Vertical, Both, None)
  • Overflow indicators (ShowOverflowIndicator property)
  • Overflow tooltip customization (OverflowIndicatorToolTipText)
  • Text manipulation methods (AppendText, Cut, Copy, Paste, Select, SelectAll)
  • ScrollToCaret() method for caret positioning

📄 阅读: references/text-configuration.md
适用场景: 配置文本属性、多行文本、字符大小写、对齐方式、溢出指示器、RTL支持
涵盖内容:
  • Text和SelectedText属性
  • CharacterCasing(大写、小写、正常大小写转换)
  • TextAlign(左对齐、居中、右对齐)
  • 面向阿拉伯语/希伯来语应用的RightToLeft布局
  • DrawActiveWhenDisabled(禁用状态下保持激活外观)
  • 多行文本配置
  • 用于换行的WordWrap属性
  • ScrollBars(水平、垂直、双向、无)
  • 溢出指示器(ShowOverflowIndicator属性)
  • 溢出提示框自定义(OverflowIndicatorToolTipText)
  • 文本操作方法(AppendText、Cut、Copy、Paste、Select、SelectAll)
  • 用于光标定位的ScrollToCaret()方法

Border Settings

边框设置

📄 Read: references/border-settings.md
When to read: Customizing border appearance, applying border colors, configuring 3D borders, selecting border sides
Topics covered:
  • BorderStyle property (Fixed3D, FixedSingle, None)
  • Border3DStyle property (Raised, Sunken, Etched, etc.)
  • BorderColor customization with Color values
  • BorderSides configuration (All, Top, Bottom, Left, Right, combinations)
  • Complete border examples with code
  • Border customization patterns
  • Matching borders to application themes

📄 阅读: references/border-settings.md
适用场景: 自定义边框外观、应用边框颜色、配置3D边框、选择显示的边框侧边
涵盖内容:
  • BorderStyle属性(Fixed3D、FixedSingle、None)
  • Border3DStyle属性(凸起、凹陷、蚀刻等)
  • 自定义BorderColor颜色值
  • BorderSides配置(全部、顶部、底部、左侧、右侧、组合)
  • 完整的边框示例代码
  • 边框自定义模式
  • 边框与应用主题的适配

Appearance and Styling

外观与样式

📄 Read: references/appearance-styling.md
When to read: Applying visual themes, customizing colors, selecting Office styles
Topics covered:
  • BackColor property for background customization
  • ForeColor property for text color
  • Style property overview
  • Eight built-in visual styles:
    • Office2016Colorful
    • Office2016White
    • Office2016Black
    • Office2016DarkGray
    • Office2019Colorful
    • Metro (flat modern design)
    • Office2007 (classic Ribbon style)
    • Office2010 (refined Office look)
    • Default (standard appearance)
  • Visual style selection and configuration
  • Style comparison examples
  • Matching textbox style to application design

📄 阅读: references/appearance-styling.md
适用场景: 应用视觉主题、自定义颜色、选择Office样式
涵盖内容:
  • 用于自定义背景的BackColor属性
  • 用于自定义文本颜色的ForeColor属性
  • Style属性概述
  • 8种内置视觉样式:
    • Office2016Colorful
    • Office2016White
    • Office2016Black
    • Office2016DarkGray
    • Office2019Colorful
    • Metro(扁平化现代设计)
    • Office2007(经典Ribbon风格)
    • Office2010(精致Office外观)
    • 默认(标准外观)
  • 视觉样式选择与配置
  • 样式对比示例
  • 文本框样式与应用设计的适配

Themes Configuration

主题配置

📄 Read: references/themes-configuration.md
When to read: Loading theme assemblies, configuring application-wide themes, runtime theme switching, advanced theming
Topics covered:
  • ThemesEnabled property (XP themes for Fixed3D borders)
  • ThemeName property for runtime theme selection
  • Theme assembly loading requirements
    • Syncfusion.Office2016Theme.WinForms (4 variations)
    • Syncfusion.Office2019Theme.WinForms
    • Syncfusion.HighContrastTheme.WinForms
  • SkinManager.LoadAssembly() method
  • Loading themes in Program.Main()
  • Office2016 theme variations (Colorful, White, Black, DarkGray)
  • Office2019Colorful theme
  • HighContrastBlack accessibility theme
  • Application-wide theme setup
  • Theme switching at runtime
  • Theme consistency across controls

📄 阅读: references/themes-configuration.md
适用场景: 加载主题程序集、配置全应用主题、运行时主题切换、高级主题设置
涵盖内容:
  • ThemesEnabled属性(用于Fixed3D边框的XP主题)
  • 用于运行时主题选择的ThemeName属性
  • 主题程序集加载要求
    • Syncfusion.Office2016Theme.WinForms(4种变体)
    • Syncfusion.Office2019Theme.WinForms
    • Syncfusion.HighContrastTheme.WinForms
  • SkinManager.LoadAssembly()方法
  • 在Program.Main()中加载主题
  • Office2016主题变体(彩色、白色、黑色、深灰)
  • Office2019Colorful主题
  • HighContrastBlack无障碍主题
  • 全应用主题设置
  • 运行时主题切换
  • 跨控件主题一致性

Behavior and Events

行为与事件

📄 Read: references/behavior-events.md
When to read: Configuring behavior properties, handling events, enforcing input restrictions, responding to property changes
Topics covered:
  • MaxLength property (input length restriction)
  • ReadOnly mode (prevent text editing)
  • Layout settings (MaximumSize, MinimumSize)
  • Twelve property-changed events:
    • Border3DStyleChanged
    • BorderColorChanged
    • BorderSidesChanged
    • BorderStyleChanged
    • CharacterCasingChanged
    • HideSelectionChanged
    • MaximumSizeChanged
    • MinimumSizeChanged
    • MultilineChanged
    • ReadOnlyChanged
    • TextAlignChanged
    • ThemesEnabledChanged
  • Event handler implementation patterns
  • Event-driven customization
  • Validation and input control scenarios
  • Dynamic property updates

📄 阅读: references/behavior-events.md
适用场景: 配置行为属性、处理事件、强制输入限制、响应属性变更
涵盖内容:
  • MaxLength属性(输入长度限制)
  • 只读模式(禁止文本编辑)
  • 布局设置(MaximumSize、MinimumSize)
  • 12个属性变更事件:
    • Border3DStyleChanged
    • BorderColorChanged
    • BorderSidesChanged
    • BorderStyleChanged
    • CharacterCasingChanged
    • HideSelectionChanged
    • MaximumSizeChanged
    • MinimumSizeChanged
    • MultilineChanged
    • ReadOnlyChanged
    • TextAlignChanged
    • ThemesEnabledChanged
  • 事件处理程序实现模式
  • 事件驱动的自定义
  • 校验与输入控制场景
  • 动态属性更新

Quick Start Example

快速入门示例

Basic Themed TextBox with Custom Border

带自定义边框的基础主题文本框

C#:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Drawing;

// Create TextBoxExt instance
TextBoxExt textBoxExt1 = new TextBoxExt();
textBoxExt1.Location = new Point(50, 50);
textBoxExt1.Size = new Size(300, 25);
textBoxExt1.Text = "Enter your text here";

// Apply Office2016 Colorful theme
textBoxExt1.Style = TextBoxExt.theme.Office2016Colorful;

// Customize border
textBoxExt1.BorderColor = Color.FromArgb(0, 120, 215); // Blue border
textBoxExt1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

// Add to form
this.Controls.Add(textBoxExt1);
VB.NET:
vb
Imports Syncfusion.Windows.Forms.Tools
Imports System.Drawing

' Create TextBoxExt instance
Dim textBoxExt1 As New TextBoxExt()
textBoxExt1.Location = New Point(50, 50)
textBoxExt1.Size = New Size(300, 25)
textBoxExt1.Text = "Enter your text here"

' Apply Office2016 Colorful theme
textBoxExt1.Style = TextBoxExt.theme.Office2016Colorful

' Customize border
textBoxExt1.BorderColor = Color.FromArgb(0, 120, 215) ' Blue border
textBoxExt1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

' Add to form
Me.Controls.Add(textBoxExt1)

C#:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Drawing;

// Create TextBoxExt instance
TextBoxExt textBoxExt1 = new TextBoxExt();
textBoxExt1.Location = new Point(50, 50);
textBoxExt1.Size = new Size(300, 25);
textBoxExt1.Text = "Enter your text here";

// Apply Office2016 Colorful theme
textBoxExt1.Style = TextBoxExt.theme.Office2016Colorful;

// Customize border
textBoxExt1.BorderColor = Color.FromArgb(0, 120, 215); // Blue border
textBoxExt1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

// Add to form
this.Controls.Add(textBoxExt1);
VB.NET:
vb
Imports Syncfusion.Windows.Forms.Tools
Imports System.Drawing

' Create TextBoxExt instance
Dim textBoxExt1 As New TextBoxExt()
textBoxExt1.Location = New Point(50, 50)
textBoxExt1.Size = New Size(300, 25)
textBoxExt1.Text = "Enter your text here"

' Apply Office2016 Colorful theme
textBoxExt1.Style = TextBoxExt.theme.Office2016Colorful

' Customize border
textBoxExt1.BorderColor = Color.FromArgb(0, 120, 215) ' Blue border
textBoxExt1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

' Add to form
Me.Controls.Add(textBoxExt1)

Common Patterns

常用模式

Pattern 1: Multiline Text Editor with Overflow Indicator

模式1:带溢出指示器的多行文本编辑器

Scenario: Create a multiline textbox for notes or comments with scrollbars and overflow tooltips
C#:
csharp
using Syncfusion.Windows.Forms.Tools;

TextBoxExt notesTextBox = new TextBoxExt();
notesTextBox.Location = new System.Drawing.Point(20, 20);
notesTextBox.Size = new System.Drawing.Size(400, 200);

// Enable multiline with word wrap
notesTextBox.Multiline = true;
notesTextBox.WordWrap = true;
notesTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;

// Configure overflow indicator
notesTextBox.ShowOverflowIndicator = true;
notesTextBox.ShowOverflowIndicatorToolTip = true;
notesTextBox.OverflowIndicatorToolTipText = "Text content exceeds visible area. Scroll to view more.";

// Apply Metro theme
notesTextBox.Style = TextBoxExt.theme.Metro;

// Add to form
this.Controls.Add(notesTextBox);

场景: 创建用于笔记或评论的多行文本框,支持滚动条和溢出提示
C#:
csharp
using Syncfusion.Windows.Forms.Tools;

TextBoxExt notesTextBox = new TextBoxExt();
notesTextBox.Location = new System.Drawing.Point(20, 20);
notesTextBox.Size = new System.Drawing.Size(400, 200);

// Enable multiline with word wrap
notesTextBox.Multiline = true;
notesTextBox.WordWrap = true;
notesTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;

// Configure overflow indicator
notesTextBox.ShowOverflowIndicator = true;
notesTextBox.ShowOverflowIndicatorToolTip = true;
notesTextBox.OverflowIndicatorToolTipText = "Text content exceeds visible area. Scroll to view more.";

// Apply Metro theme
notesTextBox.Style = TextBoxExt.theme.Metro;

// Add to form
this.Controls.Add(notesTextBox);

Pattern 2: Readonly Display Field with Active Appearance

模式2:带激活外观的只读展示字段

Scenario: Display readonly information (e.g., calculated values, status) that looks active even when disabled
C#:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Drawing;

TextBoxExt displayField = new TextBoxExt();
displayField.Location = new System.Drawing.Point(150, 100);
displayField.Size = new System.Drawing.Size(250, 25);
displayField.Text = "Total: $1,234.56";

// Make readonly but keep active appearance
displayField.ReadOnly = true;
displayField.DrawActiveWhenDisabled = true;

// Apply custom styling
displayField.BackColor = Color.WhiteSmoke;
displayField.ForeColor = Color.DarkGreen;
displayField.BorderColor = Color.LightGray;
displayField.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

// Align text to right (common for currency)
displayField.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;

// Add to form
this.Controls.Add(displayField);

场景: 展示只读信息(如计算值、状态),即使禁用也保持激活外观
C#:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Drawing;

TextBoxExt displayField = new TextBoxExt();
displayField.Location = new System.Drawing.Point(150, 100);
displayField.Size = new System.Drawing.Size(250, 25);
displayField.Text = "Total: $1,234.56";

// Make readonly but keep active appearance
displayField.ReadOnly = true;
displayField.DrawActiveWhenDisabled = true;

// Apply custom styling
displayField.BackColor = Color.WhiteSmoke;
displayField.ForeColor = Color.DarkGreen;
displayField.BorderColor = Color.LightGray;
displayField.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

// Align text to right (common for currency)
displayField.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;

// Add to form
this.Controls.Add(displayField);

Pattern 3: Uppercase Input Field with Length Restriction

模式3:带长度限制的大写输入字段

Scenario: Create an input field that automatically converts to uppercase (e.g., product codes, license keys)
C#:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Drawing;

TextBoxExt productCodeBox = new TextBoxExt();
productCodeBox.Location = new System.Drawing.Point(120, 80);
productCodeBox.Size = new System.Drawing.Size(200, 25);

// Enforce uppercase and length
productCodeBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
productCodeBox.MaxLength = 10;

// Apply Office2019 theme
productCodeBox.Style = TextBoxExt.theme.Office2019Colorful;

// Customize border
productCodeBox.BorderColor = Color.SteelBlue;
productCodeBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

// Center align for codes
productCodeBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

// Add placeholder behavior
productCodeBox.ForeColor = Color.Gray;
productCodeBox.Text = "ENTER-CODE";

productCodeBox.Enter += (s, e) => {
    if (productCodeBox.Text == "ENTER-CODE")
    {
        productCodeBox.Text = "";
        productCodeBox.ForeColor = Color.Black;
    }
};

productCodeBox.Leave += (s, e) => {
    if (string.IsNullOrWhiteSpace(productCodeBox.Text))
    {
        productCodeBox.Text = "ENTER-CODE";
        productCodeBox.ForeColor = Color.Gray;
    }
};

// Add to form
this.Controls.Add(productCodeBox);

场景: 创建可自动转换为大写的输入字段(如产品编码、许可证密钥)
C#:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Drawing;

TextBoxExt productCodeBox = new TextBoxExt();
productCodeBox.Location = new System.Drawing.Point(120, 80);
productCodeBox.Size = new System.Drawing.Size(200, 25);

// Enforce uppercase and length
productCodeBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
productCodeBox.MaxLength = 10;

// Apply Office2019 theme
productCodeBox.Style = TextBoxExt.theme.Office2019Colorful;

// Customize border
productCodeBox.BorderColor = Color.SteelBlue;
productCodeBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

// Center align for codes
productCodeBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

// Add placeholder behavior
productCodeBox.ForeColor = Color.Gray;
productCodeBox.Text = "ENTER-CODE";

productCodeBox.Enter += (s, e) => {
    if (productCodeBox.Text == "ENTER-CODE")
    {
        productCodeBox.Text = "";
        productCodeBox.ForeColor = Color.Black;
    }
};

productCodeBox.Leave += (s, e) => {
    if (string.IsNullOrWhiteSpace(productCodeBox.Text))
    {
        productCodeBox.Text = "ENTER-CODE";
        productCodeBox.ForeColor = Color.Gray;
    }
};

// Add to form
this.Controls.Add(productCodeBox);

Key Properties

核心属性

Appearance Properties

外观属性

PropertyTypeDescription
Style
TextBoxExt.theme
Visual theme: Office2016Colorful, Office2016White, Office2016Black, Office2016DarkGray, Office2019Colorful, Metro, Office2007, Office2010, Default
ThemeName
string
Runtime theme name (requires theme assembly loaded)
BackColor
Color
Background color of textbox
ForeColor
Color
Text color
BorderStyle
BorderStyle
Border style: Fixed3D, FixedSingle, None
BorderColor
Color
Custom border color
Border3DStyle
Border3DStyle
3D border effect: Raised, Sunken, Etched, etc.
BorderSides
Border3DSide
Border sides: All, Top, Bottom, Left, Right
属性类型描述
Style
TextBoxExt.theme
视觉主题:Office2016Colorful、Office2016White、Office2016Black、Office2016DarkGray、Office2019Colorful、Metro、Office2007、Office2010、默认
ThemeName
string
运行时主题名称(需先加载主题程序集)
BackColor
Color
文本框背景色
ForeColor
Color
文本颜色
BorderStyle
BorderStyle
边框样式:Fixed3D、FixedSingle、None
BorderColor
Color
自定义边框颜色
Border3DStyle
Border3DStyle
3D边框效果:凸起、凹陷、蚀刻等
BorderSides
Border3DSide
显示的边框侧边:全部、顶部、底部、左侧、右侧

Text Properties

文本属性

PropertyTypeDescription
Text
string
Textbox content
SelectedText
string
Currently selected text
CharacterCasing
CharacterCasing
Case transformation: Normal, Upper, Lower
TextAlign
HorizontalAlignment
Text alignment: Left, Center, Right
RightToLeft
RightToLeft
RTL layout: Yes, No
DrawActiveWhenDisabled
bool
Draw text as active even when control is disabled
属性类型描述
Text
string
文本框内容
SelectedText
string
当前选中的文本
CharacterCasing
CharacterCasing
大小写转换:正常、大写、小写
TextAlign
HorizontalAlignment
文本对齐:左对齐、居中、右对齐
RightToLeft
RightToLeft
RTL布局:是、否
DrawActiveWhenDisabled
bool
控件禁用时仍按激活状态绘制文本

Multiline Properties

多行属性

PropertyTypeDescription
Multiline
bool
Enable multiline text display
WordWrap
bool
Wrap text to next line automatically
ScrollBars
ScrollBars
Scrollbar visibility: None, Horizontal, Vertical, Both
属性类型描述
Multiline
bool
启用多行文本展示
WordWrap
bool
文本自动换行到下一行
ScrollBars
ScrollBars
滚动条可见性:无、水平、垂直、双向

Overflow Indicator Properties

溢出指示器属性

PropertyTypeDescription
ShowOverflowIndicator
bool
Show indicator when text overflows
ShowOverflowIndicatorToolTip
bool
Show tooltip on overflow indicator
OverflowIndicatorToolTipText
string
Custom tooltip text for overflow
属性类型描述
ShowOverflowIndicator
bool
文本溢出时显示指示器
ShowOverflowIndicatorToolTip
bool
溢出指示器上显示提示框
OverflowIndicatorToolTipText
string
溢出提示框的自定义文本

Behavior Properties

行为属性

PropertyTypeDescription
MaxLength
int
Maximum character count (default: 32767)
ReadOnly
bool
Prevent text editing
MaximumSize
Size
Maximum control dimensions
MinimumSize
Size
Minimum control dimensions
属性类型描述
MaxLength
int
最大字符数(默认:32767)
ReadOnly
bool
禁止文本编辑
MaximumSize
Size
控件最大尺寸
MinimumSize
Size
控件最小尺寸

Theme Properties

主题属性

PropertyTypeDescription
ThemesEnabled
bool
Enable XP themes for Fixed3D borders

属性类型描述
ThemesEnabled
bool
为Fixed3D边框启用XP主题

Common Use Cases

常见使用场景

1. Product Search Box with Themed Appearance

1. 带主题外观的产品搜索框

Styled textbox for searching products in inventory system:
csharp
TextBoxExt searchBox = new TextBoxExt();
searchBox.Style = TextBoxExt.theme.Office2016Colorful;
searchBox.BorderColor = Color.DodgerBlue;
searchBox.Text = "Search products...";
用于库存系统中搜索产品的样式化文本框:
csharp
TextBoxExt searchBox = new TextBoxExt();
searchBox.Style = TextBoxExt.theme.Office2016Colorful;
searchBox.BorderColor = Color.DodgerBlue;
searchBox.Text = "Search products...";

2. Multiline Description Field

2. 多行描述字段

Large textbox for product descriptions or notes:
csharp
TextBoxExt descriptionBox = new TextBoxExt();
descriptionBox.Multiline = true;
descriptionBox.WordWrap = true;
descriptionBox.ScrollBars = ScrollBars.Vertical;
descriptionBox.Size = new Size(500, 150);
用于产品描述或笔记的大尺寸文本框:
csharp
TextBoxExt descriptionBox = new TextBoxExt();
descriptionBox.Multiline = true;
descriptionBox.WordWrap = true;
descriptionBox.ScrollBars = ScrollBars.Vertical;
descriptionBox.Size = new Size(500, 150);

3. Uppercase License Key Entry

3. 大写许可证密钥输入框

Automatic uppercase conversion for license keys:
csharp
TextBoxExt licenseBox = new TextBoxExt();
licenseBox.CharacterCasing = CharacterCasing.Upper;
licenseBox.MaxLength = 25;
licenseBox.TextAlign = HorizontalAlignment.Center;
自动转换为大写的许可证密钥输入框:
csharp
TextBoxExt licenseBox = new TextBoxExt();
licenseBox.CharacterCasing = CharacterCasing.Upper;
licenseBox.MaxLength = 25;
licenseBox.TextAlign = HorizontalAlignment.Center;

4. Readonly Status Display

4. 只读状态展示框

Display-only field that shows active appearance:
csharp
TextBoxExt statusBox = new TextBoxExt();
statusBox.ReadOnly = true;
statusBox.DrawActiveWhenDisabled = true;
statusBox.BackColor = Color.LightYellow;
statusBox.Text = "Status: Active";
保持激活外观的仅展示字段:
csharp
TextBoxExt statusBox = new TextBoxExt();
statusBox.ReadOnly = true;
statusBox.DrawActiveWhenDisabled = true;
statusBox.BackColor = Color.LightYellow;
statusBox.Text = "Status: Active";

5. RTL Text Input for Arabic

5. 面向阿拉伯语的RTL文本输入框

Right-to-left textbox for international applications:
csharp
TextBoxExt arabicTextBox = new TextBoxExt();
arabicTextBox.RightToLeft = RightToLeft.Yes;
arabicTextBox.TextAlign = HorizontalAlignment.Right;
适用于国际化应用的从右到左文本框:
csharp
TextBoxExt arabicTextBox = new TextBoxExt();
arabicTextBox.RightToLeft = RightToLeft.Yes;
arabicTextBox.TextAlign = HorizontalAlignment.Right;

6. Custom Bordered Input Field

6. 自定义边框输入框

Textbox with custom border color matching brand:
csharp
TextBoxExt brandedBox = new TextBoxExt();
brandedBox.BorderStyle = BorderStyle.FixedSingle;
brandedBox.BorderColor = Color.FromArgb(255, 87, 34); // Orange
brandedBox.Style = TextBoxExt.theme.Metro;
边框颜色匹配品牌风格的文本框:
csharp
TextBoxExt brandedBox = new TextBoxExt();
brandedBox.BorderStyle = BorderStyle.FixedSingle;
brandedBox.BorderColor = Color.FromArgb(255, 87, 34); // Orange
brandedBox.Style = TextBoxExt.theme.Metro;

7. Size-Constrained Textbox

7. 尺寸受限的文本框

Textbox with enforced dimensions:
csharp
TextBoxExt constrainedBox = new TextBoxExt();
constrainedBox.MinimumSize = new Size(200, 25);
constrainedBox.MaximumSize = new Size(400, 25);

强制设置尺寸的文本框:
csharp
TextBoxExt constrainedBox = new TextBoxExt();
constrainedBox.MinimumSize = new Size(200, 25);
constrainedBox.MaximumSize = new Size(400, 25);

Additional Resources

额外资源

Assembly: Syncfusion.Shared.Base.dll
Namespace: Syncfusion.Windows.Forms.Tools
NuGet Package: Syncfusion.Shared.WinForms
Minimum .NET Framework: 4.5
Key Classes:
  • TextBoxExt
    - Main enhanced textbox control class
  • SkinManager
    - Theme assembly loading manager
Related Controls:
  • MaskedEditBox (for formatted input)
  • CurrencyTextBox (for currency values)
  • IntegerTextBox (for integer input)
  • DoubleTextBox (for decimal input)
Related Skills:
  • Form theming and styling
  • Input validation
  • Multiline text editors
  • Readonly field displays
程序集: Syncfusion.Shared.Base.dll
命名空间: Syncfusion.Windows.Forms.Tools
NuGet包: Syncfusion.Shared.WinForms
最低.NET Framework版本: 4.5
核心类:
  • TextBoxExt
    - 增强型文本框控件主类
  • SkinManager
    - 主题程序集加载管理器
相关控件:
  • MaskedEditBox(格式化输入)
  • CurrencyTextBox(货币值输入)
  • IntegerTextBox(整数输入)
  • DoubleTextBox(小数输入)
相关技能:
  • 表单主题与样式设置
  • 输入校验
  • 多行文本编辑器
  • 只读字段展示