Class CurrencyEdit
Represents the class to apply the theme for CurrencyEdit control.
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Tools
Assembly: Syncfusion.Tools.Windows.dll
Syntax
public class CurrencyEdit : ButtonEdit, IEditControlsEmbed, IButtonEditParent, IPopupParent, IPopupItem, IThemedControl, ISupportInitialize, INonClientPaintingSupport, IThemeProvider, IVisualStyle
Remarks
The CurrencyEdit class derives from ButtonEdit and embeds a CurrencyTextBox class.
The embedded CurrencyTextBox class is exposed through the TextBox property.
The CurrencyEdit has full support for the Windows Forms designer and you can just drag and drop it onto the form and set the properties.
The calculator button's visibility is controlled by the ShowCalculator property.
Examples
// CurrencyEdit control
this.currencyEdit1 = new Syncfusion.Windows.Forms.Tools.CurrencyEdit();
//
// currencyEdit1
//
this.currencyEdit1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.currencyEdit1.Location = new System.Drawing.Point(16, 80);
this.currencyEdit1.Name = "currencyEdit1";
this.currencyEdit1.SelectionLength = 0;
this.currencyEdit1.SelectionStart = 5;
this.currencyEdit1.ShowCalculator = true;
this.currencyEdit1.ShowTextBox = true;
this.currencyEdit1.Size = new System.Drawing.Size(304, 22);
this.currencyEdit1.TabIndex = 1;
this.currencyEdit1.Text = "$1.00";
this.currencyEdit1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
// Add the CurrencyEdit control to the form
this.Controls.Add(this.currencyEdit1);
' CurrencyEdit control
Me.currencyEdit1 = New Syncfusion.Windows.Forms.Tools.CurrencyEdit
'
' currencyEdit1
'
Me.currencyEdit1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.currencyEdit1.Location = New System.Drawing.Point(16, 80)
Me.currencyEdit1.Name = "currencyEdit1"
Me.currencyEdit1.SelectionLength = 0
Me.currencyEdit1.SelectionStart = 5
Me.currencyEdit1.ShowCalculator = true
Me.currencyEdit1.ShowTextBox = true
Me.currencyEdit1.Size = New System.Drawing.Size(304, 22)
Me.currencyEdit1.TabIndex = 1
Me.currencyEdit1.Text = "$1.00"
Me.currencyEdit1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
' Add the CurrencyEdit control to the form
Me.Controls.Add(Me.currencyEdit1)
Constructors
CurrencyEdit()
Initializes a new instance of the CurrencyEdit class.
Declaration
public CurrencyEdit()
Remarks
The CurrencyEdit class also creates the controls that it hosts such as the CurrencyTextBox control and the PopupCalculator control.
Properties
BeforeTouchSize
Gets/Sets Control size before touch enabled
Declaration
public Size BeforeTouchSize { get; set; }
Property Value
Type |
---|
System.Drawing.Size |
Buttons
Gets the collection of Buttons that make up this ButtonEdit control.
Declaration
public ButtonEdit.ButtonEditChildButtonCollection Buttons { get; }
Property Value
Type |
---|
ButtonEdit.ButtonEditChildButtonCollection |
CalcPopup
Gets or sets the alignment of the Popup Calculator with respect to the ButtonEdit control.
Declaration
public PopupCalculator CalcPopup { get; set; }
Property Value
Type |
---|
PopupCalculator |
Remarks
Please refer to the CalculatorPopupAlignment type for the types of alignments supported.
CalculatorButton
Gets the Calculator Button.
Declaration
public ButtonEditChildButton CalculatorButton { get; }
Property Value
Type |
---|
ButtonEditChildButton |
Remarks
The Calculator Button can be used to change the appearance of the button.
CalculatorLayoutType
Gets or sets the layout type for the Calculator Control.
Declaration
public CalculatorLayoutTypes CalculatorLayoutType { get; set; }
Property Value
Type |
---|
CalculatorLayoutTypes |
Remarks
The Calculator Control supports different layouts for Financial and Windows Standard type calculators.
The different layouts change the layout of the buttons and their appearance.
CloseAction
Gets or sets the action that will close the popup calculator.
Declaration
public CalcActions CloseAction { get; set; }
Property Value
Type |
---|
CalcActions |
Remarks
This is set to CalcOperatorEquals by default.
DecimalValue
Gets or sets the decimal value of the control. This will be formatted and displayed.
Declaration
public decimal DecimalValue { get; set; }
Property Value
Type |
---|
System.Decimal |
EnableTouchMode
Gets or sets value to enable or disable the Touchmode to the controls.
Declaration
public bool EnableTouchMode { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Scale factor will be updated automatically if scalefactor is equal to 1
Font
Gets / Sets the Font for the Calculator control.
Declaration
public override Font Font { get; set; }
Property Value
Type |
---|
System.Drawing.Font |
PopupCalculatorAlignment
Gets or sets the alignment of the Popup Calculator with respect to the ButtonEdit control.
Declaration
public CalculatorPopupAlignment PopupCalculatorAlignment { get; set; }
Property Value
Type |
---|
CalculatorPopupAlignment |
Remarks
Please refer to the CalculatorPopupAlignment type for the types of alignments supported.
ShowCalculator
Gets or sets a value indicating whether the calculator button is to be displayed. If the Calculator is not to be used, you can use the CurrencyTextBox class that is used internally by the CurrencyEdit class.
Declaration
public bool ShowCalculator { get; set; }
Property Value
Type |
---|
System.Boolean |
ShowTextBox
Indicates whether the TextBox is to be displayed.
Declaration
public override bool ShowTextBox { get; }
Property Value
Type |
---|
System.Boolean |
Overrides
Text
Overrides the Text property.
Declaration
public override string Text { get; set; }
Property Value
Type |
---|
System.String |
Overrides
Remarks
The Text property is not persisted.
TextBox
Gets the CurrencyTextBox control that defines the Currency behavior for this control.
Declaration
public CurrencyTextBox TextBox { get; }
Property Value
Type |
---|
CurrencyTextBox |
Remarks
See the CurrencyTextBox control for more information.
TransferFromCalculator
Gets or sets a value indicating whether to transfer the calculated value to the edit control.
Declaration
public bool TransferFromCalculator { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Indicates whether the calculated value is to be transferred to the CurrencyTextBox when the popup calculator is closed.
TransferToCalculator
Gets or sets a value indicating whether to transfer the values from the edit control to the calculator.
Declaration
public bool TransferToCalculator { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Indicates whether the current currency value of the CurrencyTextBox is to be transferred to the CalculatorControl when the Calculator is dropped down.
Methods
ApplyScaleToControl(Single)
Scale the control based on the scale factor passed in the argument.
Declaration
public void ApplyScaleToControl(float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
System.Single | scaleFactor | value to scale the factor based upon. |
AttachTextBox()
Declaration
public override void AttachTextBox()
Overrides
ChildButtonsRemovedByDesigner(ArrayList)
Stores the child buttons removed by the designer in a separate arraylist to prevent serialization
Declaration
public void ChildButtonsRemovedByDesigner(ArrayList childButtons)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.ArrayList | childButtons | Arraylist containing the child buttons |
CreateAccessibilityInstance()
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
Type |
---|
System.Windows.Forms.AccessibleObject |
CreateTextBox()
Sets the CurrencyTextBox as the TextBox for this control.
Declaration
protected override TextBoxExt CreateTextBox()
Returns
Type | Description |
---|---|
TextBoxExt | A CurrencyTextBox object. |
Overrides
Remarks
This override of the CreateTextBox method allows us to change the default TextBox object that will be created with a CurrencyTextBox object.
DetachTextBox()
Declaration
public override void DetachTextBox()
Overrides
Dispose(Boolean)
Cleans up any resources being used.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Bool disposing |
Overrides
DrawBackground(Graphics, Rectangle)
Draws the background of control depending on ReadOnly property .
Declaration
protected override void DrawBackground(Graphics g, Rectangle rect)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | The System.Drawing.Graphics context. |
System.Drawing.Rectangle | rect | The System.Drawing.Rectangle within which to draw. |
Overrides
Remarks
Draws the background with ReadOnlyBackColor when control is set to ReadOnly.Else,with default BackColor.
HandleTextBoxKeyDownEvent(Object, KeyEventArgs)
Handles the KeyDown event of the embedded TextBox and drops down the Calculator Control.
Declaration
protected void HandleTextBoxKeyDownEvent(object sender, KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The TextBox. |
System.Windows.Forms.KeyEventArgs | e | The event args. |
InitializeLayout()
Initializes the layout for the CurrencyEdit control. Overrides InitializeLayout in ButtonEdit.
Declaration
public void InitializeLayout()
OnCalculatorClosing(CalculatorClosingEventArgs)
Invokes the CalculatorClosing event.
Declaration
protected virtual void OnCalculatorClosing(CalculatorClosingEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
CalculatorClosingEventArgs | args | A CancelEventArgs that contains the event data. |
Remarks
The OnPopupCalculatorClosing method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
note
Inheritors: When overriding OnStyleChanged in a derived class, be sure to call the base class's OnStyleChanged method so that registered delegates receive the event.
OnCalculatorShowing(CancelEventArgs)
Invokes the BeforeCalculatorPopupDisplay event.
Declaration
protected virtual bool OnCalculatorShowing(CancelEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.CancelEventArgs | args | A BeforeCalculatorPopupDisplayEventArgs that contains the event data. |
Returns
Type | Description |
---|---|
System.Boolean | True if hte Calculator is showing. |
Remarks
The OnBeforeCalculatorPopupDisplay method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
note
Inheritors: When overriding OnBeforeCalculatorPopupDisplay in a derived class, be sure to call the base class's OnBeforeCalculatorPopupDisplay method so that registered delegates receive the event.
OnDecimalValueChanged(EventArgs)
Raises the DecimalValueChanged event.
Declaration
protected virtual void OnDecimalValueChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | A System.EventArgs that contains the event data. |
OnEndInit()
Declaration
protected override void OnEndInit()
Overrides
OnLayout(LayoutEventArgs)
Declaration
protected override void OnLayout(LayoutEventArgs levent)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.LayoutEventArgs | levent |
Overrides
OnSizeChanged(EventArgs)
Declaration
protected override void OnSizeChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
Overrides
OnThemeNameChanged(String)
Helps to apply the ThemeName settings in control
Declaration
public override void OnThemeNameChanged(string themeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | themeName | ThemeName |
Overrides
OnValidating(CancelEventArgs)
Raises the System.Windows.Forms.Control.Validating event.
Declaration
protected override void OnValidating(CancelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.CancelEventArgs | e | A System.ComponentModel.CancelEventArgs that contains the event data. |
Remarks
Overridden
OnValidationError(ValidationErrorArgs)
Invokes the ValidationError event.
Declaration
protected virtual void OnValidationError(ValidationErrorArgs args)
Parameters
Type | Name | Description |
---|---|---|
ValidationErrorArgs | args | A ValidationErrorEventArgs that contains the event data. |
Remarks
The OnValidationError method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
note
Inheritors: When overriding OnValidationError in a derived class, be sure to call the base class's OnValidationError method so that registered delegates receive the event.
RaiseCalculatorClosingEvent(CalculatorCloseType)
Raises the CalculatorClosing event. This event is raised by the calculator control before the popup calculator closes when the '=' button is clicked. This event will not be raised when the popup calculator control closes when it loses focus.
Declaration
protected void RaiseCalculatorClosingEvent(CalculatorCloseType closeType)
Parameters
Type | Name | Description |
---|---|---|
CalculatorCloseType | closeType | Calculator close type |
RaiseCalculatorShowingEvent()
This method raises the CalculatorShowing event.
Declaration
protected bool RaiseCalculatorShowingEvent()
Returns
Type | Description |
---|---|
System.Boolean | True if the Calculator display has been cancelled by a event handler; false otherwise. |
Remarks
This event can be handled if you want to make some changes to the Calculator Control before it is displayed.
Events
CalculatorClosing
Event raised by a popup calculator when closing after the specified button was clicked.
Declaration
public event PopupCalculatorClosingEventHandler CalculatorClosing
Event Type
Type |
---|
PopupCalculatorClosingEventHandler |
Remarks
By default the CalculatorControl will raise this event when the specified button is clicked. This event can be canceled by a handler and the PopupCalculator will not be closed.
CalculatorShowing
Event raised before the calculator popup is displayed.
Declaration
public event CancelEventHandler CalculatorShowing
Event Type
Type |
---|
System.ComponentModel.CancelEventHandler |
Remarks
This event is a System.ComponentModel.CancelEventHandler type event. You can cancel the PopupCalculator from being displayed by handling this event.
DecimalValueChanged
Occurs when the DecimalValue property is changed.
Declaration
public event EventHandler DecimalValueChanged
Event Type
Type |
---|
System.EventHandler |
ValidationError
Raised when an unacceptable character is encountered as input.
Declaration
public event ValidationErrorEventHandler ValidationError
Event Type
Type |
---|
ValidationErrorEventHandler |
Remarks
This event can be handled and you can do your processing based on the information provided. The ValidationErrorEventArgs object will provide the invalid text that was input and also the position within that text where the error occurred.
Examples
Console.WriteLine("ValidationError in currencyTextBox1 InvalidText" + e.InvalidText);
Console.WriteLine("ValidationError in currencyTextBox1 StartPosition" + e.StartPosition );
Console.WriteLine(("ValidationError in currencyTextBox1 InvalidText" + e.InvalidText))
Console.WriteLine(("ValidationError in currencyTextBox1 StartPosition" + e.StartPosition))
Explicit Interface Implementations
IVisualStyle.VisualTheme
Declaration
string IVisualStyle.VisualTheme { get; set; }
Returns
Type |
---|
System.String |