Loading...
Loading...
Compare original and translation side by side
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;
public partial class Form1 : Form
{
private CurrencyTextBox currencyTextBox1;
public Form1()
{
InitializeComponent();
// Create and configure CurrencyTextBox
currencyTextBox1 = new CurrencyTextBox();
currencyTextBox1.Location = new System.Drawing.Point(10, 10);
currencyTextBox1.Size = new System.Drawing.Size(200, 25);
// Set currency format
currencyTextBox1.CurrencySymbol = "$";
currencyTextBox1.CurrencyDecimalDigits = 2;
currencyTextBox1.CurrencyGroupSeparator = ",";
currencyTextBox1.CurrencyGroupSizes = new int[] { 3 };
// Set value constraints
currencyTextBox1.MaxValue = 999999.99m;
currencyTextBox1.MinValue = 0m;
currencyTextBox1.DecimalValue = 100.00m;
// Set colors for value states
currencyTextBox1.PositiveColor = System.Drawing.Color.Black;
currencyTextBox1.NegativeColor = System.Drawing.Color.Red;
currencyTextBox1.ZeroColor = System.Drawing.Color.Gray;
this.Controls.Add(currencyTextBox1);
}
}using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;
public partial class Form1 : Form
{
private CurrencyTextBox currencyTextBox1;
public Form1()
{
InitializeComponent();
// Create and configure CurrencyTextBox
currencyTextBox1 = new CurrencyTextBox();
currencyTextBox1.Location = new System.Drawing.Point(10, 10);
currencyTextBox1.Size = new System.Drawing.Size(200, 25);
// Set currency format
currencyTextBox1.CurrencySymbol = "$";
currencyTextBox1.CurrencyDecimalDigits = 2;
currencyTextBox1.CurrencyGroupSeparator = ",";
currencyTextBox1.CurrencyGroupSizes = new int[] { 3 };
// Set value constraints
currencyTextBox1.MaxValue = 999999.99m;
currencyTextBox1.MinValue = 0m;
currencyTextBox1.DecimalValue = 100.00m;
// Set colors for value states
currencyTextBox1.PositiveColor = System.Drawing.Color.Black;
currencyTextBox1.NegativeColor = System.Drawing.Color.Red;
currencyTextBox1.ZeroColor = System.Drawing.Color.Gray;
this.Controls.Add(currencyTextBox1);
}
}// For collecting currency amounts (payments, invoices, etc.)
currencyTextBox.MaxValue = decimal.MaxValue;
currencyTextBox.MinValue = 0m;
currencyTextBox.CurrencySymbol = "$";
currencyTextBox.CurrencyDecimalDigits = 2;
currencyTextBox.AllowNull = false;// For collecting currency amounts (payments, invoices, etc.)
currencyTextBox.MaxValue = decimal.MaxValue;
currencyTextBox.MinValue = 0m;
currencyTextBox.CurrencySymbol = "$";
currencyTextBox.CurrencyDecimalDigits = 2;
currencyTextBox.AllowNull = false;// Color-code by sign (green for profit, red for loss)
currencyTextBox.PositiveColor = System.Drawing.Color.Green;
currencyTextBox.NegativeColor = System.Drawing.Color.Red;
currencyTextBox.MaxValue = decimal.MaxValue;
currencyTextBox.MinValue = decimal.MinValue;// Color-code by sign (green for profit, red for loss)
currencyTextBox.PositiveColor = System.Drawing.Color.Green;
currencyTextBox.NegativeColor = System.Drawing.Color.Red;
currencyTextBox.MaxValue = decimal.MaxValue;
currencyTextBox.MinValue = decimal.MinValue;// Allow null values with custom placeholder text
currencyTextBox.AllowNull = true;
currencyTextBox.NullString = "(Not Specified)";
currencyTextBox.Text = "";// Allow null values with custom placeholder text
currencyTextBox.AllowNull = true;
currencyTextBox.NullString = "(未填写)";
currencyTextBox.Text = "";// Handle KeyDown event to add multiplier shortcuts
private void currencyTextBox1_KeyDown(object sender, KeyEventArgs e)
{
decimal value = currencyTextBox1.DecimalValue;
switch(e.KeyCode)
{
case Keys.G: // Giga (billion)
currencyTextBox1.DecimalValue = value * 1000000000m;
break;
case Keys.M: // Mega (million)
currencyTextBox1.DecimalValue = value * 1000000m;
break;
case Keys.K: // Kilo (thousand)
currencyTextBox1.DecimalValue = value * 1000m;
break;
}
}// Handle KeyDown event to add multiplier shortcuts
private void currencyTextBox1_KeyDown(object sender, KeyEventArgs e)
{
decimal value = currencyTextBox1.DecimalValue;
switch(e.KeyCode)
{
case Keys.G: // Giga (十亿)
currencyTextBox1.DecimalValue = value * 1000000000m;
break;
case Keys.M: // Mega (百万)
currencyTextBox1.DecimalValue = value * 1000000m;
break;
case Keys.K: // Kilo (千)
currencyTextBox1.DecimalValue = value * 1000m;
break;
}
}| Property | Type | Purpose | Common Values |
|---|---|---|---|
| DecimalValue | decimal | Get/set numeric value programmatically | Any valid decimal |
| CurrencySymbol | string | Currency symbol display | "$", "€", "£", "¥" |
| CurrencyDecimalDigits | int | Decimal places displayed | 2, 3, 4 |
| CurrencyGroupSeparator | string | Thousands separator | ",", ".", " " |
| MaxValue | decimal | Maximum allowed value | 999999.99, 100000, etc. |
| MinValue | decimal | Minimum allowed value | 0, -999999.99, etc. |
| PositiveColor | Color | Color for positive values | Color.Black, Color.Green |
| NegativeColor | Color | Color for negative values | Color.Red, Color.Maroon |
| ZeroColor | Color | Color for zero value | Color.Gray, Color.DarkGray |
| TextAlign | HorizontalAlignment | Text position | Left, Center, Right |
| BorderStyle | BorderStyle | Border appearance | FixedSingle, Fixed3D, None |
| AllowNull | bool | Allow empty/null values | true, false |
| ShowOverflowIndicator | bool | Show indicator when value exceeds bounds | true, false |
| 属性 | 类型 | 用途 | 常用值 |
|---|---|---|---|
| DecimalValue | decimal | 以程序方式读取/设置数值 | 任意合法decimal值 |
| CurrencySymbol | string | 展示的货币符号 | "$", "€", "£", "¥" |
| CurrencyDecimalDigits | int | 展示的小数位数 | 2, 3, 4 |
| CurrencyGroupSeparator | string | 千位分隔符 | ",", ".", " " |
| MaxValue | decimal | 允许的最大值 | 999999.99, 100000等 |
| MinValue | decimal | 允许的最小值 | 0, -999999.99等 |
| PositiveColor | Color | 正值的展示颜色 | Color.Black, Color.Green |
| NegativeColor | Color | 负值的展示颜色 | Color.Red, Color.Maroon |
| ZeroColor | Color | 零值的展示颜色 | Color.Gray, Color.DarkGray |
| TextAlign | HorizontalAlignment | 文本对齐方式 | 左对齐, 居中, 右对齐 |
| BorderStyle | BorderStyle | 边框外观 | FixedSingle, Fixed3D, None |
| AllowNull | bool | 是否允许空/Null值 | true, false |
| ShowOverflowIndicator | bool | 数值超出范围时是否展示指示器 | true, false |