用途:本技能用于在 Windows Forms 应用中实现 Syncfusion 的 IntegerTextBox 控件,创建只接受整数、带实时数值校验和格式化能力的输入字段。
主要能力:控件派生自标准 TextBox,仅接受和显示整数;通过 MinValue、MaxValue 强制上下界约束;支持 NumberGroupSeparator 和 NumberGroupSizes 自定义数字分组分隔符;支持 AllowLeadingZeros 前导零、负数处理与 DeleteSelectionOnNegative;通过 BindableValue 提供可空包装;可用 PositiveColor、NegativeColor、ZeroColor 按值类型着色,并支持 BackColor、ReadOnlyBackColor、ReadOnly 等外观与状态设置;提供 BindableValueChanged、IntegerValueChanged、ValidationError、FormattedTextChanged、ClipTextChanged 等事件。
使用方式:引用程序集 Syncfusion.Shared.Base,引入命名空间 Syncfusion.Windows.Forms.Tools,可在设计器或 C# 代码中创建控件。示例:IntegerTextBox integerTextBox1 = new IntegerTextBox(); this.Controls.Add(integerTextBox1); integerTextBox1.MaxValue = 999999; integerTextBox1.MinValue = -999999; integerTextBox1.IntegerValue = 0; 事件示例:integerTextBox1.BindableValueChanged += (sender, e) => MessageBox.Show($"New value: {integerTextBox1.IntegerValue}"); 安装与 NuGet 包配置参见参考资料,本资料未列出具体命令。
适用场景:金融金额输入(如 0 至 999999 并加千位分隔符)、温度等含负数范围输入、只读展示数值、可空整数并带校验错误提示。
限制:控件仅限整数类型,格式化不涉及主题和本地化;具体安装命令、收费与平台要求本资料暂未提供,需查阅官方文档确认。