Implementing Syncfusion Windows Forms CurrencyTextBox
Syncfusion CurrencyTextBox is a specialized text input control derived from System.Windows.Forms.TextBox
that provides currency-specific validation, formatting, and behavior. It handles keyboard input validation,
culture-aware decimal formatting, and value constraints automatically.
When to Use This Skill
- Creating currency input fields with automatic validation
- Building financial data entry forms (invoices, payments, budgets)
- Implementing currency display with positive/negative color coding
- Working with decimal precision and grouping separators
- Handling clipboard operations with currency data
- Adding keyboard shortcuts for multiplying values (Mega, Kilo, etc.)
- Enforcing minimum and maximum currency values
- Displaying overflow indicators for large numbers
Component Overview
The CurrencyTextBox control intercepts user keyboard input and prevents entry of invalid currency characters.
It automatically formats the display based on decimal digits, group separators, and the currency symbol.
Unlike the standard TextBox, it validates against min/max bounds and supports currency-specific events.
Key Capabilities:
- Automatic keyboard input validation
- Culture-aware decimal formatting
- Max/Min value constraints with enforcement
- Positive, negative, and zero value color coding
- Clipboard support with optional format stripping
- Overflow indicators with tooltips
- Keyboard shortcuts for multiplying values
- ValidationError event for invalid input handling
Documentation Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Installation and assembly dependencies
- Creating a project and adding the control
- Designer and code-based control creation
- Setting up MaxValue/MinValue constraints
- Configuring currency symbols
- Basic control properties
Text Field Customization
📄 Read: references/text-field-customization.md
- Text display and alignment (Left, Center, Right)
- Multiline support with word wrapping
- Password character masking
- Banner text for empty state
- Number and decimal digit formatting
- Handling negative values and signs
- Null string configuration
Value Formatting
📄 Read: references/value-formatting.md
- DecimalValue programmatic access
- Currency symbol customization
- Number formatting (total digits before decimal)
- Decimal digit precision
- Group separator configuration
- Removing trailing decimal zeros
- Currency positive and negative patterns
Event Handling
📄 Read: references/event-handling.md
- KeyDown event for keyboard shortcuts
- Adding multiplier keys (G, M, K for Giga/Mega/Kilo)
- ValidationError event for invalid input
- Error message handling with StartPosition
- Using ErrorProvider for visual feedback
- Custom validation scenarios
Appearance Customization
📄 Read: references/appearance-customization.md
- Border styles (FixedSingle, Fixed3D, None)
- 3D border effects (Raised, Sunken, Flat, etc.)
- Border color and side configuration
- Color coding by value (Positive, Negative, Zero)
- ReadOnly background color
- Visual style application
Advanced Features
📄 Read: references/advanced-features.md
- Clipboard support with formatting options
- Overflow indicator display
- Overflow indicator tooltips
- Multiple clipboard modes
- Data preservation strategies
Validation and Constraints
📄 Read: references/validation-and-constraints.md
- Setting min/max boundaries
- Enforcing constraints during validation
- Negative input behavior with selected text
- AllowNull configuration
- NullString custom display values
- Value range enforcement
Quick Start Example
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);
}
}
Common Patterns
Currency Entry Form
// For collecting currency amounts (payments, invoices, etc.)
currencyTextBox.MaxValue = decimal.MaxValue;
currencyTextBox.MinValue = 0m;
currencyTextBox.CurrencySymbol = "$";
currencyTextBox.CurrencyDecimalDigits = 2;
currencyTextBox.AllowNull = false;
Profit/Loss Display
// 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;
Optional Amount with Placeholder
// Allow null values with custom placeholder text
currencyTextBox.AllowNull = true;
currencyTextBox.NullString = "(Not Specified)";
currencyTextBox.Text = "";
Keyboard Shortcuts for Large Numbers
// 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;
}
}
Key Properties Reference
| 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 |
Use Cases by Scenario
Financial Application
- Use positive/negative color coding
- Set MaxValue to prevent data type overflow
- Handle ValidationError for audit logging
- Support clipboard for paste operations
Budget Entry Form
- Set reasonable MaxValue (e.g., 999999.99)
- Use TextAlign.Right for numeric convention
- Display banner text for required fields
- Enforce MinValue of 0 if amounts must be positive
Multi-Currency Display
- Change CurrencySymbol based on user locale
- Keep CurrencyDecimalDigits consistent (usually 2)
- Adjust CurrencyGroupSeparator per region
- Display DecimalValue consistently in database
Large Number Handling
- Enable keyboard multiplier shortcuts (G, M, K)
- Use ShowOverflowIndicator for values exceeding visible space
- Remove decimal zeros with RemoveDecimalZeros property
- Increase number digits with CurrencyNumberDigits
Next Steps
- Choose the reference file matching your task
- Implement the control following the code examples
- Test with both valid and edge-case values
- Handle ValidationError event for invalid input
- Use DecimalValue for business logic, Text for display
1---2name: syncfusion-winforms-currency-textbox3description: Implement currency input controls in Windows Forms applications using Syncfusion CurrencyTextBox. Use this skill when developers need to create currency entry fields with validation, formatting, decimal handling, positive/negative color coding, and clipboard support. Essential for financial forms, payment inputs, budget applications, and any scenario requiring validated currency input.4---56# Implementing Syncfusion Windows Forms CurrencyTextBox78Syncfusion CurrencyTextBox is a specialized text input control derived from System.Windows.Forms.TextBox9that provides currency-specific validation, formatting, and behavior. It handles keyboard input validation,10culture-aware decimal formatting, and value constraints automatically.1112## When to Use This Skill1314- Creating currency input fields with automatic validation15- Building financial data entry forms (invoices, payments, budgets)16- Implementing currency display with positive/negative color coding17- Working with decimal precision and grouping separators18- Handling clipboard operations with currency data19- Adding keyboard shortcuts for multiplying values (Mega, Kilo, etc.)20- Enforcing minimum and maximum currency values21- Displaying overflow indicators for large numbers2223## Component Overview2425The CurrencyTextBox control intercepts user keyboard input and prevents entry of invalid currency characters.26It automatically formats the display based on decimal digits, group separators, and the currency symbol.27Unlike the standard TextBox, it validates against min/max bounds and supports currency-specific events.2829**Key Capabilities:**30- Automatic keyboard input validation31- Culture-aware decimal formatting32- Max/Min value constraints with enforcement33- Positive, negative, and zero value color coding34- Clipboard support with optional format stripping35- Overflow indicators with tooltips36- Keyboard shortcuts for multiplying values37- ValidationError event for invalid input handling3839## Documentation Navigation Guide4041### Getting Started42📄 **Read:** [references/getting-started.md](references/getting-started.md)43- Installation and assembly dependencies44- Creating a project and adding the control45- Designer and code-based control creation46- Setting up MaxValue/MinValue constraints47- Configuring currency symbols48- Basic control properties4950### Text Field Customization51📄 **Read:** [references/text-field-customization.md](references/text-field-customization.md)52- Text display and alignment (Left, Center, Right)53- Multiline support with word wrapping54- Password character masking55- Banner text for empty state56- Number and decimal digit formatting57- Handling negative values and signs58- Null string configuration5960### Value Formatting61📄 **Read:** [references/value-formatting.md](references/value-formatting.md)62- DecimalValue programmatic access63- Currency symbol customization64- Number formatting (total digits before decimal)65- Decimal digit precision66- Group separator configuration67- Removing trailing decimal zeros68- Currency positive and negative patterns6970### Event Handling71📄 **Read:** [references/event-handling.md](references/event-handling.md)72- KeyDown event for keyboard shortcuts73- Adding multiplier keys (G, M, K for Giga/Mega/Kilo)74- ValidationError event for invalid input75- Error message handling with StartPosition76- Using ErrorProvider for visual feedback77- Custom validation scenarios7879### Appearance Customization80📄 **Read:** [references/appearance-customization.md](references/appearance-customization.md)81- Border styles (FixedSingle, Fixed3D, None)82- 3D border effects (Raised, Sunken, Flat, etc.)83- Border color and side configuration84- Color coding by value (Positive, Negative, Zero)85- ReadOnly background color86- Visual style application8788### Advanced Features89📄 **Read:** [references/advanced-features.md](references/advanced-features.md)90- Clipboard support with formatting options91- Overflow indicator display92- Overflow indicator tooltips93- Multiple clipboard modes94- Data preservation strategies9596### Validation and Constraints97📄 **Read:** [references/validation-and-constraints.md](references/validation-and-constraints.md)98- Setting min/max boundaries99- Enforcing constraints during validation100- Negative input behavior with selected text101- AllowNull configuration102- NullString custom display values103- Value range enforcement104105## Quick Start Example106107```csharp108using System.Windows.Forms;109using Syncfusion.Windows.Forms.Tools;110111public partial class Form1 : Form112{113 private CurrencyTextBox currencyTextBox1;114 115 public Form1()116 {117 InitializeComponent();118 119 // Create and configure CurrencyTextBox120 currencyTextBox1 = new CurrencyTextBox();121 currencyTextBox1.Location = new System.Drawing.Point(10, 10);122 currencyTextBox1.Size = new System.Drawing.Size(200, 25);123 124 // Set currency format125 currencyTextBox1.CurrencySymbol = "$";126 currencyTextBox1.CurrencyDecimalDigits = 2;127 currencyTextBox1.CurrencyGroupSeparator = ",";128 currencyTextBox1.CurrencyGroupSizes = new int[] { 3 };129 130 // Set value constraints131 currencyTextBox1.MaxValue = 999999.99m;132 currencyTextBox1.MinValue = 0m;133 currencyTextBox1.DecimalValue = 100.00m;134 135 // Set colors for value states136 currencyTextBox1.PositiveColor = System.Drawing.Color.Black;137 currencyTextBox1.NegativeColor = System.Drawing.Color.Red;138 currencyTextBox1.ZeroColor = System.Drawing.Color.Gray;139 140 this.Controls.Add(currencyTextBox1);141 }142}143```144145## Common Patterns146147### Currency Entry Form148```csharp149// For collecting currency amounts (payments, invoices, etc.)150currencyTextBox.MaxValue = decimal.MaxValue;151currencyTextBox.MinValue = 0m;152currencyTextBox.CurrencySymbol = "$";153currencyTextBox.CurrencyDecimalDigits = 2;154currencyTextBox.AllowNull = false;155```156157### Profit/Loss Display158```csharp159// Color-code by sign (green for profit, red for loss)160currencyTextBox.PositiveColor = System.Drawing.Color.Green;161currencyTextBox.NegativeColor = System.Drawing.Color.Red;162currencyTextBox.MaxValue = decimal.MaxValue;163currencyTextBox.MinValue = decimal.MinValue;164```165166### Optional Amount with Placeholder167```csharp168// Allow null values with custom placeholder text169currencyTextBox.AllowNull = true;170currencyTextBox.NullString = "(Not Specified)";171currencyTextBox.Text = "";172```173174### Keyboard Shortcuts for Large Numbers175```csharp176// Handle KeyDown event to add multiplier shortcuts177private void currencyTextBox1_KeyDown(object sender, KeyEventArgs e)178{179 decimal value = currencyTextBox1.DecimalValue;180 switch(e.KeyCode)181 {182 case Keys.G: // Giga (billion)183 currencyTextBox1.DecimalValue = value * 1000000000m;184 break;185 case Keys.M: // Mega (million)186 currencyTextBox1.DecimalValue = value * 1000000m;187 break;188 case Keys.K: // Kilo (thousand)189 currencyTextBox1.DecimalValue = value * 1000m;190 break;191 }192}193```194195## Key Properties Reference196197| Property | Type | Purpose | Common Values |198|----------|------|---------|----------------|199| DecimalValue | decimal | Get/set numeric value programmatically | Any valid decimal |200| CurrencySymbol | string | Currency symbol display | "$", "€", "£", "¥" |201| CurrencyDecimalDigits | int | Decimal places displayed | 2, 3, 4 |202| CurrencyGroupSeparator | string | Thousands separator | ",", ".", " " |203| MaxValue | decimal | Maximum allowed value | 999999.99, 100000, etc. |204| MinValue | decimal | Minimum allowed value | 0, -999999.99, etc. |205| PositiveColor | Color | Color for positive values | Color.Black, Color.Green |206| NegativeColor | Color | Color for negative values | Color.Red, Color.Maroon |207| ZeroColor | Color | Color for zero value | Color.Gray, Color.DarkGray |208| TextAlign | HorizontalAlignment | Text position | Left, Center, Right |209| BorderStyle | BorderStyle | Border appearance | FixedSingle, Fixed3D, None |210| AllowNull | bool | Allow empty/null values | true, false |211| ShowOverflowIndicator | bool | Show indicator when value exceeds bounds | true, false |212213## Use Cases by Scenario214215**Financial Application**216- Use positive/negative color coding217- Set MaxValue to prevent data type overflow218- Handle ValidationError for audit logging219- Support clipboard for paste operations220221**Budget Entry Form**222- Set reasonable MaxValue (e.g., 999999.99)223- Use TextAlign.Right for numeric convention224- Display banner text for required fields225- Enforce MinValue of 0 if amounts must be positive226227**Multi-Currency Display**228- Change CurrencySymbol based on user locale229- Keep CurrencyDecimalDigits consistent (usually 2)230- Adjust CurrencyGroupSeparator per region231- Display DecimalValue consistently in database232233**Large Number Handling**234- Enable keyboard multiplier shortcuts (G, M, K)235- Use ShowOverflowIndicator for values exceeding visible space236- Remove decimal zeros with RemoveDecimalZeros property237- Increase number digits with CurrencyNumberDigits238239## Next Steps240241- Choose the reference file matching your task242- Implement the control following the code examples243- Test with both valid and edge-case values244- Handle ValidationError event for invalid input245- Use DecimalValue for business logic, Text for display