syncfusion-winforms-domainupdownext
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing DomainUpdownExt in Windows Forms
在Windows Forms中实现DomainUpdownExt
DomainUpdownExt is an advanced Windows Forms control that provides a modern dropdown interface with spin buttons for value selection. It's ideal for scenarios where users need to browse through a predefined list of items using increment/decrement buttons or keyboard navigation.
DomainUpdownExt是一款高级Windows Forms控件,提供带微调按钮的现代化下拉界面用于值选择,非常适合用户需要通过增减按钮或键盘导航浏览预定义选项列表的场景。
When to Use This Skill
何时使用本技能
Use this skill when you need to:
- Create a dropdown control with spin button navigation
- Allow users to browse through a list of predefined values
- Customize control appearance (borders, colors, styles)
- Enable arrow key navigation for value selection
- Configure text alignment and spin button orientation
- Handle user interactions and keyboard events
- Add dynamic items based on user input
当你需要实现以下需求时可以使用本技能:
- 创建带微调按钮导航的下拉控件
- 允许用户浏览预定义值列表
- 自定义控件外观(边框、颜色、样式)
- 支持方向键导航选择值
- 配置文本对齐方式和微调按钮朝向
- 处理用户交互和键盘事件
- 根据用户输入添加动态选项
Component Overview
组件概览
DomainUpdownExt combines the functionality of a text box with spin buttons and a predefined list of items. Unlike a standard ComboBox, it displays only the current item and lets users navigate through the list using arrow keys or spin buttons.
Key Capabilities:
- Item management with programmatic access
- Spin button customization (orientation, alignment)
- Keyboard support (arrow keys, keyboard events)
- Appearance customization (borders, colors, text alignment)
- Event handling for state changes
- Text and item validation
DomainUpdownExt结合了文本框、微调按钮和预定义选项列表的功能。与标准ComboBox不同,它仅显示当前选中项,用户可通过方向键或微调按钮浏览列表。
核心功能:
- 支持编程方式的选项管理
- 微调按钮自定义(朝向、对齐方式)
- 键盘支持(方向键、键盘事件)
- 外观自定义(边框、颜色、文本对齐)
- 状态变化的事件处理
- 文本和选项校验
Documentation and Navigation Guide
文档和导航指南
Getting Started
入门
📄 Read: references/getting-started.md
- Assembly dependencies and project setup
- Adding control via designer
- Adding control manually in code
- Creating your first DomainUpdownExt control
- Basic item management
📄 阅读: references/getting-started.md
- 程序集依赖和项目设置
- 通过设计器添加控件
- 手动在代码中添加控件
- 创建你的第一个DomainUpdownExt控件
- 基础选项管理
Text and Item Management
文本和选项管理
📄 Read: references/text-and-items.md
- Adding and removing items from the collection
- Text alignment properties
- MaxLength configuration
- Managing selected items programmatically
- Item validation patterns
📄 阅读: references/text-and-items.md
- 从集合中添加和移除选项
- 文本对齐属性
- MaxLength配置
- 编程方式管理选中项
- 选项校验模式
Spin Button Control
微调按钮控制
📄 Read: references/spinbutton-control.md
- SpinOrientation property (horizontal vs. vertical)
- UpDownAlign property (left vs. right alignment)
- Configuring spin button appearance
- Default button behaviors
📄 阅读: references/spinbutton-control.md
- SpinOrientation属性(水平 vs 垂直)
- UpDownAlign属性(左对齐 vs 右对齐)
- 配置微调按钮外观
- 默认按钮行为
Appearance and Customization
外观和自定义
📄 Read: references/appearance-customization.md
- Border styles and properties
- Background and foreground colors
- Border 3D styles
- Customizing control look and feel
- Visual appearance patterns
📄 阅读: references/appearance-customization.md
- 边框样式和属性
- 背景和前景色
- 3D边框样式
- 自定义控件外观和质感
- 视觉外观模式
Keyboard Navigation and Interaction
键盘导航和交互
📄 Read: references/keyboard-and-interaction.md
- Arrow key support (InterceptArrowKeys property)
- KeyDown event handling
- UpButton and DownButton methods
- Programmatic value browsing
- Keyboard navigation patterns
📄 阅读: references/keyboard-and-interaction.md
- 方向键支持(InterceptArrowKeys属性)
- KeyDown事件处理
- UpButton和DownButton方法
- 编程方式浏览值
- 键盘导航模式
Advanced Usage and Patterns
高级用法和模式
📄 Read: references/advanced-usage.md
- Adding items at runtime based on user input
- Programmatic navigation through values
- Event handling strategies
- Common use cases and patterns
- Best practices for interaction design
📄 阅读: references/advanced-usage.md
- 运行时根据用户输入添加选项
- 编程方式浏览值
- 事件处理策略
- 常见用例和模式
- 交互设计最佳实践
Quick Start Example
快速入门示例
Create a basic DomainUpdownExt control with items and keyboard navigation:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Windows.Forms;
public class Form1 : Form
{
private DomainUpDownExt domainUpDownExt1;
public Form1()
{
// Create control
domainUpDownExt1 = new DomainUpDownExt();
// Add items
domainUpDownExt1.Items.Add("Option 1");
domainUpDownExt1.Items.Add("Option 2");
domainUpDownExt1.Items.Add("Option 3");
domainUpDownExt1.Items.Add("Option 4");
// Configure appearance
domainUpDownExt1.BorderStyle = BorderStyle.FixedSingle;
domainUpDownExt1.BackColor = System.Drawing.Color.White;
domainUpDownExt1.SpinOrientation = Orientation.Vertical;
// Enable keyboard navigation
domainUpDownExt1.InterceptArrowKeys = true;
// Add to form
this.Controls.Add(domainUpDownExt1);
}
}创建一个带选项和键盘导航的基础DomainUpdownExt控件:
csharp
using Syncfusion.Windows.Forms.Tools;
using System.Windows.Forms;
public class Form1 : Form
{
private DomainUpDownExt domainUpDownExt1;
public Form1()
{
// Create control
domainUpDownExt1 = new DomainUpDownExt();
// Add items
domainUpDownExt1.Items.Add("Option 1");
domainUpDownExt1.Items.Add("Option 2");
domainUpDownExt1.Items.Add("Option 3");
domainUpDownExt1.Items.Add("Option 4");
// Configure appearance
domainUpDownExt1.BorderStyle = BorderStyle.FixedSingle;
domainUpDownExt1.BackColor = System.Drawing.Color.White;
domainUpDownExt1.SpinOrientation = Orientation.Vertical;
// Enable keyboard navigation
domainUpDownExt1.InterceptArrowKeys = true;
// Add to form
this.Controls.Add(domainUpDownExt1);
}
}Common Patterns
常见模式
Pattern 1: Vertical Spin Button with Right Alignment
模式1:右对齐垂直微调按钮
csharp
domainUpDownExt1.SpinOrientation = Orientation.Vertical;
domainUpDownExt1.UpDownAlign = LeftRightAlignment.Right;csharp
domainUpDownExt1.SpinOrientation = Orientation.Vertical;
domainUpDownExt1.UpDownAlign = LeftRightAlignment.Right;Pattern 2: Horizontal Spin Button with Left Alignment
模式2:左对齐水平微调按钮
csharp
domainUpDownExt1.SpinOrientation = Orientation.Horizontal;
domainUpDownExt1.UpDownAlign = LeftRightAlignment.Left;csharp
domainUpDownExt1.SpinOrientation = Orientation.Horizontal;
domainUpDownExt1.UpDownAlign = LeftRightAlignment.Left;Pattern 3: Custom Appearance with Colored Border
模式3:带彩色边框的自定义外观
csharp
domainUpDownExt1.BorderStyle = BorderStyle.FixedSingle;
domainUpDownExt1.BorderColor = System.Drawing.Color.Blue;
domainUpDownExt1.BackColor = System.Drawing.Color.LightGray;csharp
domainUpDownExt1.BorderStyle = BorderStyle.FixedSingle;
domainUpDownExt1.BorderColor = System.Drawing.Color.Blue;
domainUpDownExt1.BackColor = System.Drawing.Color.LightGray;Pattern 4: Programmatic Navigation
模式4:编程式导航
csharp
domainUpDownExt1.UpButton(); // Navigate to previous item
domainUpDownExt1.DownButton(); // Navigate to next itemcsharp
domainUpDownExt1.UpButton(); // Navigate to previous item
domainUpDownExt1.DownButton(); // Navigate to next itemKey Properties
核心属性
| Property | Type | Purpose | Common Values |
|---|---|---|---|
| Collection | Gets the collection of items | Add/Remove items |
| Int32 | Gets/sets the selected item index | 0 to Items.Count - 1 |
| String | Gets/sets the current display text | Any string |
| Orientation | Controls spin button direction | Vertical, Horizontal |
| LeftRightAlignment | Controls spin button position | Left, Right |
| Boolean | Enable/disable arrow key navigation | true, false |
| BorderStyle | Sets border appearance | FixedSingle, Fixed3D, None |
| Color | Sets border color | Any System.Drawing.Color |
| Color | Sets background color | Any System.Drawing.Color |
| HorizontalAlignment | Controls text alignment | Left, Center, Right |
| Int32 | Maximum text length | 0 to 32768 |
| 属性 | 类型 | 用途 | 常用值 |
|---|---|---|---|
| Collection | 获取选项集合 | 添加/移除选项 |
| Int32 | 获取/设置选中项索引 | 0 到 Items.Count - 1 |
| String | 获取/设置当前显示文本 | 任意字符串 |
| Orientation | 控制微调按钮方向 | 垂直, 水平 |
| LeftRightAlignment | 控制微调按钮位置 | 左, 右 |
| Boolean | 启用/禁用方向键导航 | true, false |
| BorderStyle | 设置边框外观 | FixedSingle, Fixed3D, None |
| Color | 设置边框颜色 | 任意System.Drawing.Color值 |
| Color | 设置背景颜色 | 任意System.Drawing.Color值 |
| HorizontalAlignment | 控制文本对齐 | 左, 居中, 右 |
| Int32 | 最大文本长度 | 0 到 32768 |
Common Use Cases
常见用例
- Numeric Range Selection - Allow users to select values from a predefined range
- Category Navigation - Browse through predefined categories or options
- Status Selection - Choose from discrete status values in a compact interface
- Configuration Options - Select from a set of predefined configuration values
- Priority Levels - Choose priority from a discrete set of values
- Difficulty Levels - Select difficulty/intensity levels with spin navigation
- 数值范围选择 - 允许用户从预定义范围中选择值
- 类别导航 - 浏览预定义类别或选项
- 状态选择 - 在紧凑界面中从离散状态值中选择
- 配置选项 - 从一组预定义配置值中选择
- 优先级级别 - 从离散值集合中选择优先级
- 难度级别 - 通过微调导航选择难度/强度级别