Class TextAsValueHelper
Provides helper methods for TextBox and similar controls to use text as value.
public class TextAsValueHelper : BaseObject, IBaseObject, IObjectToStringOptions, IValidatorReporter
- Inheritance
-
TextAsValueHelper
- Implements
- Extension Methods
Constructors
- TextAsValueHelper(AbstractControl)
Initializes a new instance of the TextAsValueHelper class.
Fields
- CreateOverride
An override of the Create(AbstractControl) method.
Properties
- AllowEmptyText
Gets or sets a value indicating whether empty string is allowed in Text.
- AutoShowError
Gets or sets whether error reporter is automatically shown/hidden when error state is changed.
- Context
Gets or sets ITypeDescriptorContext value which is used when text to/from value is converted using TypeConverter.
- Converter
Gets or sets IObjectToString provider which is used in value to string convertion.
- Culture
Gets or sets CultureInfo value which is used when text to/from value is converted using TypeConverter.
- DefaultFormat
Gets or sets default format used in value to string convertion.
- DefaultText
Gets or sets default value for the Text property.
- DefaultValidatorErrorText
Gets or sets a text string that can be used as a default validator error message.
- EmptyTextValue
Gets or sets data value in cases when Text property is empty.
- FormatProvider
Gets or sets an object that supplies culture-specific formatting information.
- InputType
Gets or sets input type. Default is Null.
- InputTypeArgs
Gets or sets init arguments which are used when InputType property is assigned.
- IsHexNumber
Gets whether NumberStyles has HexNumber flag.
- IsMinValueNegativeOrNull
Gets whether MinValue is specified and negative.
- IsNullOrEmpty
Gets whether Text is null or empty.
- IsNullOrWhiteSpace
Gets whether Text is null or white space.
- IsRequired
Gets or sets a value indicating whether Text is required to be not empty. This is an opposite of AllowEmptyText property.
- IsSignedInt
Gets whether DataType specifies a signed integer number (int, long, sbyte, short). Additionally MinValue is also checked whether it allows negative numbers.
- IsSignedNumber
Gets whether DataType specifies a signed number. Additionally MinValue is also checked whether it allows negative numbers.
- IsUnsignedInt
Gets whether DataType specifies an unsigned integer number (uint, ulong, byte, ushort).
- MaxLength
Gets or sets the maximum number of characters the user can enter into the control.
- MaxValue
Gets or sets the maximum value that can be entered in the control.
- MinLength
Gets or sets the minimum number of characters the user must enter into the control.
- MinValue
Gets or sets the minimum value that can be entered in the control.
- NumberStyles
Gets or sets a bitwise combination of NumberStyles values that indicates the permitted format of the text.
- Options
Gets or sets flags which customize behavior and visual style of the control.
- ResetErrorBackgroundMethod
Gets or sets method which is used to clear error state if error background color is used for reporting it.
- ResetErrorForegroundMethod
Gets or sets method which is used to clear error state if error foreground color is used for reporting it.
- Search
Gets or sets string search provider.
- Text
Provides access to the text property of the owner control.
- TextAsNumber
Gets or sets Text property value as object of a number type.
- TextAsValue
Gets or sets Text as object using DataType, TypeConverter and other properties which define text to/from value conversion rules.
- TextAsValueError
Gets last error occurred inside TextAsValue property getter or setter.
- TrimTextRules
Gets or sets text trimming rules used in TextAsValue setter and some other places.
- TypeConverter
Gets or sets TypeConverter used for the text to/from value conversion. You also need to specify UseTypeConverter in Options.
- UseInvariantCulture
Gets or sets a value indicating whether invariant culture is used for text to/from value conversion.
- ValidatorErrorText
Gets or sets a text string that can be used as validator error message.
- ValidatorReporter
Gets or sets validator reporter object or control.
Methods
- Create(AbstractControl)
Creates instance of TextAsValueHelper class.
- DataTypeIsNumber()
Returns
trueif DataType is a number type.
- GetErrors()
Gets the validation errors.
- GetKnownErrorText(ValueValidatorKnownError)
Gets known error text.
- GetMinMaxRangeStr(string?, bool)
Returns minimal and maximal possible values for the DataType as a range string and formats it using
format.
- GetMinValueAsString(bool)
Gets minimal possible value as string.
- GetRealMaxValue()
Gets "real" maximal value taking into account DataType and MinValue.
- GetRealMinValue()
Gets "real" minimal value taking into account DataType and MinValue.
- HasErrorEmptyText()
Gets 'Empty Text' error status if empty text is not allowed.
- HasErrorMaxLength()
Gets 'Max Length' error status if MaxLength is specified.
- HasErrorMinLength()
Gets 'Min Length' error status if MinLength is specified.
- InitAsByte(bool, byte?)
Initializes data validation for byte values.
- InitAsDouble(bool, double?)
Initializes data validation for double values.
- InitAsInt16(bool, short?)
Initializes data validation for short values.
- InitAsInt32(bool, int?)
Initializes data validation for int values.
- InitAsInt64(bool, long?)
Initializes data validation for long values.
- InitAsSignedByte(bool, sbyte?)
Initializes data validation for sbyte values.
- InitAsSingle(bool, float?)
Initializes data validation for float values.
- InitAsUnsignedDouble(bool, double?)
Initializes data validation for unsigned double values.
- InitAsUnsignedInt16(bool, ushort?)
Initializes data validation for ushort values.
- InitAsUnsignedInt32(bool, uint?)
Initializes data validation for uint values.
- InitAsUnsignedInt64(bool, ulong?)
Initializes data validation for ulong values.
- InitAsUnsignedSingle(bool, float?)
Initializes data validation for unsigned float values.
- InitErrorPicture(PictureBox)
Initializes PictureBox with error image and other options.
- ObjectToString(object?, TextBoxOptions?)
Converts the specified object to string using conversion rules specified in the control.
- ReportErrorBadNumber(Action<string>?)
Reports an error if DataType is a number type and TextAsNumber is
null.
- ReportErrorEmptyText(Action<string>?)
Reports an error if Text property is empty and it is not allowed (AllowEmptyText is
false).
- ReportErrorMinMaxLength(Action<string>?)
Reports an error if length of the Text property value is less than MinLength or greater than MaxLength.
- ReportErrorMinMaxValue(object?, Action<string>?)
Reports an error if
valueis less than MinValue or greater than MaxValue.
- ReportValidatorError(bool, string?, Action<string>?)
Reports text validation error.
- ResetInputSettings()
Resets fields and properties before editing new value with the different data type. You can call this method in order to reset members related to data type, formatting and value conversion.
- RunDefaultValidation(Action<string>?)
Runs default validation of the Text property.
- SetErrorStatus(object?, bool, string?)
Sets error status.
- SetErrorText(ValueValidatorKnownError)
Sets ValidatorErrorText property to
knownError.
- SetErrorTextFromDataType()
Sets ValidatorErrorText with default error text for the data type specified in DataType.
- SetTextAsByte(byte)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsDateTime(DateTime)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsDecimal(decimal)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsDouble(double)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsInt16(short)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsInt32(int)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsInt64(long)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsNumber(NumericTypeCode, object)
Assigns DataType from the specified
typeCodeand calls SetTextAsObject(object?).
- SetTextAsObject(object?)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsSByte(sbyte)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsSingle(float)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsUInt16(ushort)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsUInt32(uint)
Converts
valueto string and assigns Text property with the converted value.
- SetTextAsUInt64(ulong)
Converts
valueto string and assigns Text property with the converted value.
- SetValidator(Type?, bool)
Sets DataType to the specified type and and CharValidator to the appropriate validator provider.
- SetValueAndValidator(object?, bool)
Sets text as value (using SetTextAsObject(object?)) and assigns appropriate char and value validators.
- TextAsNumberOrDefault<T>(T)
Returns TextAsNumber or
defValueif it isnull.
- UseCharValidator<T>()
Sets DataType property to
Tand CharValidator to the appropriate validator provider.
Events
- ErrorStatusChanged
Occurs when ReportValidatorError(bool, string?, Action<string>?) is called.
- GlobalStringToValue
Occurs when string is converted to value. This is static event and is called for all the editors.
- GlobalValueToString
Occurs when value is converted to string. This is static event and is called for all the editors.
- StringToValue
Occurs when string is converted to value in this control.
- ValueToString
Occurs when value is converted to string in this control.