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
AccessibilityEnabled
Gets or sets a value indicating whether the control should enable its Accessibility support.
Declaration
public bool AccessibilityEnabled { get; set; }
Property Value
AllowNull
Gets or sets the NULL string to be displayed.
Declaration
public override bool AllowNull { get; set; }
Property Value
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
ClipText
Returns the clipped text without the formatting.
Declaration
public override string ClipText { get; }
Property Value
Overrides
DoubleValue
Gets / sets the double value of the control. This will be formatted and
displayed.
Declaration
public double DoubleValue { get; set; }
Property Value
FormattedText
Declaration
public override string FormattedText { get; }
Property Value
Overrides
MaxValue
Gets / sets the maximum value that can be set through the PercentTextBox.
Declaration
public double MaxValue { get; set; }
Property Value
MinValue
Gets / sets the minimum value that can be set through the PercentTextBox.
Declaration
public double MinValue { get; set; }
Property Value
PercentDecimalDigits
Gets / sets the maximum number of digits for the decimal portion of the percentage.
Declaration
public int PercentDecimalDigits { get; set; }
Property Value
PercentDecimalSeparator
Gets / sets the decimal separator character that will be used for the display.
Declaration
public string PercentDecimalSeparator { get; set; }
Property Value
PercentGroupSeparator
Gets / sets the separator to be used for grouping digits.
Declaration
public string PercentGroupSeparator { get; set; }
Property Value
PercentGroupSizes
Gets / sets the grouping of PercentDigits in the PercentTextBox.
Declaration
public int[] PercentGroupSizes { get; set; }
Property Value
PercentNegativePattern
Gets / sets the pattern to use when the value is negative.
Declaration
public int PercentNegativePattern { get; set; }
Property Value
PercentNegativePatterns
Declaration
protected string[] PercentNegativePatterns { get; set; }
Property Value
PercentPositivePattern
Gets / sets the pattern to use when the value is positive.
Declaration
public int PercentPositivePattern { get; set; }
Property Value
PercentSymbol
Gets / sets the percent symbol to be used in the PercentTextBox.
Declaration
public string PercentSymbol { get; set; }
Property Value
PercentValue
Gets / sets the percent value of the control. This will be formatted and
displayed.
Declaration
public double PercentValue { get; set; }
Property Value
SwitchModeOnFocus
Indicates whether the PercentTextBox should allow editing in numeric mode
when it receives focus.
Declaration
public bool SwitchModeOnFocus { get; set; }
Property Value
Text
Overrides the Text property of System.Windows.Forms.TextBox.
Declaration
public override string Text { get; set; }
Property Value
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
Overrides
CheckForMinMax(String, Boolean)
Declaration
protected override bool CheckForMinMax(string currentTextValue, bool ignoreLength)
Parameters
Type |
Name |
Description |
System.String |
currentTextValue |
|
System.Boolean |
ignoreLength |
|
Returns
Overrides
CheckIfNegative(String)
Declaration
protected override bool CheckIfNegative(string rawValue)
Parameters
Type |
Name |
Description |
System.String |
rawValue |
|
Returns
Overrides
CheckIsZero()
Declaration
protected override bool CheckIsZero()
Returns
Overrides
CompleteSubtractKey(NumberModifyState)
Declaration
protected override bool CompleteSubtractKey(NumberModifyState state)
Parameters
Returns
Overrides
CreateAccessibilityInstance()
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
Type |
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
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
Overrides
GetDecimalDigits()
Declaration
protected override int GetDecimalDigits()
Returns
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
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
Overrides
GetNumberPartLength(Double)
Declaration
protected int GetNumberPartLength(double numberValue)
Parameters
Type |
Name |
Description |
System.Double |
numberValue |
|
Returns
GetNumberValue(String, Int32)
Declaration
protected override string GetNumberValue(string formattedText, int startPosition)
Parameters
Type |
Name |
Description |
System.String |
formattedText |
|
System.Int32 |
startPosition |
|
Returns
Overrides
GetValue()
Declaration
protected override object GetValue()
Returns
Overrides
HandleBackspaceKey()
Declaration
protected override bool HandleBackspaceKey()
Returns
Overrides
HandleBackspaceKeyChar()
Declaration
protected override bool HandleBackspaceKeyChar()
Returns
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
Overrides
HandleDecimalKey()
Declaration
protected override bool HandleDecimalKey()
Returns
Overrides
HandleDeleteKey()
Declaration
protected override bool HandleDeleteKey()
Returns
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
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
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
ShouldSerializePercentGroupSeparator()
Indicates whether PercentGroupSeparator should not be serialized if
the UseLocaleDefault property is set.
Declaration
protected bool ShouldSerializePercentGroupSeparator()
Returns
ShouldSerializePercentGroupSizes()
Indicates whether the PercentGroupPattern should not be serialized if
the UseLocaleDefault property is set.
Declaration
protected bool ShouldSerializePercentGroupSizes()
Returns
ShouldSerializeText()
Indicates whether to serialize the Text property
if it is null or quals NullString
Declaration
protected bool ShouldSerializeText()
Returns
ToggleNegative(String)
Declaration
protected override string ToggleNegative(string currentText)
Parameters
Type |
Name |
Description |
System.String |
currentText |
|
Returns
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
Overrides
Events
BindablePercentValueChanged
Declaration
public event EventHandler BindablePercentValueChanged
Event Type
DoubleValueChanged
Declaration
public event EventHandler DoubleValueChanged
Event Type
Implements
System.ComponentModel.ISupportInitialize
System.Runtime.Serialization.ISerializable