Class PercentTextBox
Extends the System.Windows.Forms.TextBox class to handle percentage input
and validation.
Inheritance
System.Object
PercentTextBox
Implements
System.ComponentModel.ISupportInitialize
System.Runtime.Serialization.ISerializable
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class PercentTextBox : NumberTextBoxBase, IThemeProvider, ISupportInitialize, ISerializable, IVisualStyle
Constructors
PercentTextBox()
Overloaded. Creates an object of type PercentTextBox.
Declaration
Properties
AllowNull
Gets or sets the NULL string to be displayed.
Declaration
public override bool AllowNull { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Overrides
BindablePercentValue
Wrapper property around the selected value. Use this property if you
want to be able to set the value of the control to NULL.
Declaration
public object BindablePercentValue { get; set; }
Property Value
Type |
Description |
System.Object |
|
ClipText
Returns the clipped text without the formatting.
Declaration
public override string ClipText { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
DoubleValue
Gets / sets the double value of the control. This will be formatted and
displayed.
Declaration
public double DoubleValue { get; set; }
Property Value
Type |
Description |
System.Double |
|
FormattedText
Declaration
public override string FormattedText { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
MaxValue
Gets / sets the maximum value that can be set through the PercentTextBox.
Declaration
public double MaxValue { get; set; }
Property Value
Type |
Description |
System.Double |
|
MinValue
Gets / sets the minimum value that can be set through the PercentTextBox.
Declaration
public double MinValue { get; set; }
Property Value
Type |
Description |
System.Double |
|
PercentDecimalDigits
Gets / sets the maximum number of digits for the decimal portion of the percentage.
Declaration
public int PercentDecimalDigits { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
PercentDecimalSeparator
Gets / sets the decimal separator character that will be used for the display.
Declaration
public string PercentDecimalSeparator { get; set; }
Property Value
Type |
Description |
System.String |
|
PercentGroupSeparator
Gets / sets the separator to be used for grouping digits.
Declaration
public string PercentGroupSeparator { get; set; }
Property Value
Type |
Description |
System.String |
|
PercentGroupSizes
Gets / sets the grouping of PercentDigits in the PercentTextBox.
Declaration
public int[] PercentGroupSizes { get; set; }
Property Value
Type |
Description |
System.Int32[] |
|
PercentNegativePattern
Gets / sets the pattern to use when the value is negative.
Declaration
public int PercentNegativePattern { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
PercentNegativePatterns
Declaration
protected string[] PercentNegativePatterns { get; set; }
Property Value
Type |
Description |
System.String[] |
|
PercentPositivePattern
Gets / sets the pattern to use when the value is positive.
Declaration
public int PercentPositivePattern { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
PercentSymbol
Gets / sets the percent symbol to be used in the PercentTextBox.
Declaration
public string PercentSymbol { get; set; }
Property Value
Type |
Description |
System.String |
|
PercentValue
Gets / sets the percent value of the control. This will be formatted and
displayed.
Declaration
public double PercentValue { get; set; }
Property Value
Type |
Description |
System.Double |
|
SwitchModeOnFocus
Indicates whether the PercentTextBox should allow editing in numeric mode
when it receives focus.
Declaration
public bool SwitchModeOnFocus { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Text
Overrides the Text property of System.Windows.Forms.TextBox.
Declaration
public override string Text { get; set; }
Property Value
Type |
Description |
System.String |
|
ThemeStyle
Declaration
public PercentTextBoxVisualStyle ThemeStyle { get; set; }
Property Value
Methods
ApplyFormatting(String)
Formats the given text according to the current setting.
Declaration
protected override string ApplyFormatting(string rawValue)
Parameters
Type |
Name |
Description |
System.String |
rawValue |
|
Returns
Type |
Description |
System.String |
|
Overrides
CheckForMinMax(String, Boolean)
Declaration
protected override bool CheckForMinMax(string currentTextValue, bool ignoreLength)
Parameters
Type |
Name |
Description |
System.String |
currentTextValue |
|
System.Boolean |
ignoreLength |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
CheckIfNegative(String)
Declaration
protected override bool CheckIfNegative(string rawValue)
Parameters
Type |
Name |
Description |
System.String |
rawValue |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
CheckIsZero()
Declaration
protected override bool CheckIsZero()
Returns
Type |
Description |
System.Boolean |
|
Overrides
CompleteSubtractKey(NumberModifyState)
Declaration
protected override bool CompleteSubtractKey(NumberModifyState state)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
CreateAccessibilityInstance()
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
Type |
Description |
System.Windows.Forms.AccessibleObject |
|
Overrides
Dispose(Boolean)
Clean up any resources being used.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type |
Name |
Description |
System.Boolean |
disposing |
|
Overrides
FormatChanged(String, NumberFormatInfo)
Declaration
protected override void FormatChanged(string currentText, NumberFormatInfo previousFormat)
Parameters
Type |
Name |
Description |
System.String |
currentText |
|
System.Globalization.NumberFormatInfo |
previousFormat |
|
Overrides
GetAdjustedValue(Double)
Declaration
public virtual double GetAdjustedValue(double newValue)
Parameters
Type |
Name |
Description |
System.Double |
newValue |
|
Returns
Type |
Description |
System.Double |
|
GetControlName(String)
Helps to override the ThemeName property settings
Declaration
public override string GetControlName(string controlName)
Parameters
Type |
Name |
Description |
System.String |
controlName |
ThemeName
|
Returns
Type |
Description |
System.String |
|
Overrides
GetDecimalDigits()
Declaration
protected override int GetDecimalDigits()
Returns
Type |
Description |
System.Int32 |
|
Overrides
GetDecimalSeparator(NumberFormatInfo)
Override this to return PercentDecimalSeparator in PercentTextBox.
Declaration
protected override string GetDecimalSeparator(NumberFormatInfo info)
Parameters
Type |
Name |
Description |
System.Globalization.NumberFormatInfo |
info |
|
Returns
Type |
Description |
System.String |
|
Overrides
GetGroupSeparator(NumberFormatInfo)
Override this to return PercentGroupSeparator in PercentTextBox.
Declaration
protected override string GetGroupSeparator(NumberFormatInfo info)
Parameters
Type |
Name |
Description |
System.Globalization.NumberFormatInfo |
info |
|
Returns
Type |
Description |
System.String |
|
Overrides
GetNumberPartLength(Double)
Declaration
protected int GetNumberPartLength(double numberValue)
Parameters
Type |
Name |
Description |
System.Double |
numberValue |
|
Returns
Type |
Description |
System.Int32 |
|
GetNumberValue(String, Int32)
Declaration
protected override string GetNumberValue(string formattedText, int startPosition)
Parameters
Type |
Name |
Description |
System.String |
formattedText |
|
System.Int32 |
startPosition |
|
Returns
Type |
Description |
System.String |
|
Overrides
GetValue()
Declaration
protected override object GetValue()
Returns
Type |
Description |
System.Object |
|
Overrides
HandleBackspaceKey()
Declaration
protected override bool HandleBackspaceKey()
Returns
Type |
Description |
System.Boolean |
|
Overrides
HandleBackspaceKeyChar()
Declaration
protected override bool HandleBackspaceKeyChar()
Returns
Type |
Description |
System.Boolean |
|
Overrides
HandleCharacterKey(Char)
Overrides the base behavior to implement support for NumberMode. In this mode, the
base behavior of formatting each key is not followed. The key is validated internally to check for
Max and Min conditions and then displayed as is without the formatting. The key will be ignored if
the supressKeyPress value is not set to False. This is set to False when a valid key press is encountered.
Declaration
protected override bool HandleCharacterKey(char charToBeInserted)
Parameters
Type |
Name |
Description |
System.Char |
charToBeInserted |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
HandleDecimalKey()
Declaration
protected override bool HandleDecimalKey()
Returns
Type |
Description |
System.Boolean |
|
Overrides
HandleDeleteKey()
Declaration
protected override bool HandleDeleteKey()
Returns
Type |
Description |
System.Boolean |
|
Overrides
HandleSubtractKey()
Invoked when the negative key is pressed.
Declaration
protected override NumberModifyState HandleSubtractKey()
Returns
Overrides
Remarks
InitializeNumberTextBox()
Declaration
protected override void InitializeNumberTextBox()
Overrides
IsAssignable(Object)
Declaration
protected override bool IsAssignable(object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
OnBindablePercentValueChanged(EventArgs)
Declaration
protected virtual void OnBindablePercentValueChanged(EventArgs e)
Parameters
Type |
Name |
Description |
System.EventArgs |
e |
A System.EventArgs that contains the event data.
|
OnDoubleValueChanged(EventArgs)
Declaration
protected virtual void OnDoubleValueChanged(EventArgs e)
Parameters
Type |
Name |
Description |
System.EventArgs |
e |
A System.EventArgs that contains the event data.
|
OnEnabledChanged(EventArgs)
Raises the System.Windows.Forms.Control.EnabledChanged event.
Declaration
protected override void OnEnabledChanged(EventArgs e)
Parameters
Type |
Name |
Description |
System.EventArgs |
e |
An System.EventArgs that contains the event data.
|
Overrides
OnEnter(EventArgs)
Overrides the System.Windows.Forms.Control.OnEnter(System.EventArgs) method.
Declaration
protected override void OnEnter(EventArgs args)
Parameters
Type |
Name |
Description |
System.EventArgs |
args |
The event data.
|
Overrides
OnGotFocus(EventArgs)
Helps to override the OnGotFocus events
Declaration
protected override void OnGotFocus(EventArgs e)
Parameters
Type |
Name |
Description |
System.EventArgs |
e |
An System.EventArgs that contains the event data.
|
Overrides
OnLeave(EventArgs)
Overrides the System.Windows.Forms.Control.OnLeave(System.EventArgs) method.
Declaration
protected override void OnLeave(EventArgs args)
Parameters
Type |
Name |
Description |
System.EventArgs |
args |
|
OnTextChanged(EventArgs)
Declaration
protected override void OnTextChanged(EventArgs e)
Parameters
Type |
Name |
Description |
System.EventArgs |
e |
The event data.
|
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
OnValidated(EventArgs)
Declaration
protected override void OnValidated(EventArgs e)
Parameters
Type |
Name |
Description |
System.EventArgs |
e |
|
OnValidating(CancelEventArgs)
Declaration
protected override void OnValidating(CancelEventArgs e)
Parameters
Type |
Name |
Description |
System.ComponentModel.CancelEventArgs |
e |
|
Overrides
ParseForNegativeFormat(String, NumberFormatInfo)
Declaration
protected override bool ParseForNegativeFormat(string currentText, NumberFormatInfo info)
Parameters
Type |
Name |
Description |
System.String |
currentText |
The text to be parsed.
|
System.Globalization.NumberFormatInfo |
info |
|
Returns
Type |
Description |
System.Boolean |
True if the value is negative; false otherwise.
|
Overrides
Paste()
Pastes the data in the clipboard into the PercentTextBox control.
Declaration
PrepareInsertString(String, Int32, Int32, String, Boolean)
Declaration
protected override NumberModifyState PrepareInsertString(string currentText, int startPosition, int selectionLength, string textToBeInserted, bool pasteOperation)
Parameters
Type |
Name |
Description |
System.String |
currentText |
|
System.Int32 |
startPosition |
|
System.Int32 |
selectionLength |
|
System.String |
textToBeInserted |
|
System.Boolean |
pasteOperation |
|
Returns
Overrides
RemoveFormatting(String, NumberFormatInfo, Boolean)
Declaration
protected override string RemoveFormatting(string formattedText, NumberFormatInfo info, bool padIfEmpty)
Parameters
Type |
Name |
Description |
System.String |
formattedText |
|
System.Globalization.NumberFormatInfo |
info |
|
System.Boolean |
padIfEmpty |
|
Returns
Type |
Description |
System.String |
|
Overrides
ResetMaxValue()
Resets the value to the default.
Declaration
public void ResetMaxValue()
ResetMinValue()
Resets the value to the default.
Declaration
public void ResetMinValue()
ResetText()
Restores the CurrencyNumberDigits to the MaximumLength.
Declaration
protected void ResetText()
SetDoubleValue(Double)
Declaration
protected void SetDoubleValue(double newValue)
Parameters
Type |
Name |
Description |
System.Double |
newValue |
|
SetNullNumberValue()
Declaration
protected override void SetNullNumberValue()
Overrides
SetNullState(Double)
Declaration
protected void SetNullState(double val)
Parameters
Type |
Name |
Description |
System.Double |
val |
|
SetPercentValue(Object)
Declaration
protected void SetPercentValue(object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
SetTextProperty(String)
Declaration
protected override void SetTextProperty(string newText)
Parameters
Type |
Name |
Description |
System.String |
newText |
|
Overrides
SetValue(Object)
Declaration
protected override void SetValue(object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
Overrides
ShouldSerializeMaxValue()
Indicates whether the MaxValue property should be serialized.
Declaration
public bool ShouldSerializeMaxValue()
Returns
Type |
Description |
System.Boolean |
True if the value is not equal to System.Double.MaxValue.
|
ShouldSerializeMinValue()
Indicates whether the MinValue property should be serialized.
Declaration
public bool ShouldSerializeMinValue()
Returns
Type |
Description |
System.Boolean |
True if the value is not equal to System.Decimal.MaxValue.
|
ShouldSerializePercentDecimalSeparator()
Indicates whether the PercentDecimalSeparator should not be serialized if
the UseLocaleDefault property is set.
Declaration
protected bool ShouldSerializePercentDecimalSeparator()
Returns
Type |
Description |
System.Boolean |
|
ShouldSerializePercentGroupSeparator()
Indicates whether PercentGroupSeparator should not be serialized if
the UseLocaleDefault property is set.
Declaration
protected bool ShouldSerializePercentGroupSeparator()
Returns
Type |
Description |
System.Boolean |
|
ShouldSerializePercentGroupSizes()
Indicates whether the PercentGroupPattern should not be serialized if
the UseLocaleDefault property is set.
Declaration
protected bool ShouldSerializePercentGroupSizes()
Returns
Type |
Description |
System.Boolean |
|
ShouldSerializeText()
Indicates whether to serialize the Text property
if it is null or quals NullString
Declaration
protected bool ShouldSerializeText()
Returns
Type |
Description |
System.Boolean |
|
ToggleNegative(String)
Declaration
protected override string ToggleNegative(string currentText)
Parameters
Type |
Name |
Description |
System.String |
currentText |
|
Returns
Type |
Description |
System.String |
|
Overrides
Validate(Boolean)
Declaration
public override bool Validate(bool bRaiseValidationError)
Parameters
Type |
Name |
Description |
System.Boolean |
bRaiseValidationError |
Indicates whether the validation error is to be raised.
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
Events
BindablePercentValueChanged
Declaration
public event EventHandler BindablePercentValueChanged
Event Type
Type |
Description |
System.EventHandler |
|
DoubleValueChanged
Declaration
public event EventHandler DoubleValueChanged
Event Type
Type |
Description |
System.EventHandler |
|
Implements
System.ComponentModel.ISupportInitialize
System.Runtime.Serialization.ISerializable