GrapeCity MultiRow Windows Forms Documentation
RequiredType Property (RequiredTypeValidator)
Example 


Gets or sets the specified value's required System.Type.
Syntax
<DefaultValueAttribute()>
<TypeConverterAttribute("GrapeCity.Win.MultiRow.Design.RequiredTypeCoverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<SRDescriptionAttribute("Indicates the specified value's desired type.")>
Public Property RequiredType As Type
Dim instance As RequiredTypeValidator
Dim value As Type
 
instance.RequiredType = value
 
value = instance.RequiredType
[DefaultValue()]
[TypeConverter("GrapeCity.Win.MultiRow.Design.RequiredTypeCoverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[SRDescription("Indicates the specified value's desired type.")]
public Type RequiredType {get; set;}

Property Value

A System.Type value that represents the specified value's required System.Type. The default is a null reference (Nothing in Visual Basic).
Example
TThe following code example uses the RequiredTypeValidator to validate whether the original value's type is System.Decimal. A balloon tip is displayed to show the validation failed. Enter edit mode, type a value, and press the Esc key to cancel editing to see this. The validation fails because the original value "I'm string type" is not a decimal value. This example is part of a larger example available for the CellValidator class.
void setRequiredTypeValidator_Click(object sender, EventArgs e)
        {
            Template template = Template.CreateGridTemplate(1);

            RequiredTypeValidator requiredTypeValidator = new RequiredTypeValidator();
            requiredTypeValidator.RequiredType = typeof(decimal);

            TipNotify tipNotify = new TipNotify();
            tipNotify.ToolTipIcon = ToolTipIcon.Warning;
            tipNotify.ToolTipSpan = 6000;
            tipNotify.ToolTipTitle = "Requird Type Error";
            tipNotify.ToolTipText = "The original value is not Decimal type";
            //When you escape edit mode, the acion is done (press ESC key)
            tipNotify.DoActionReason = ValidateReasons.CancelEdit;
            requiredTypeValidator.Actions.Add(tipNotify);

            //When cancel edit, this value is validated.
            template.Row.Cells[0].Value = "I'm a string type";
            template.Row.Cells[0].Validators.Add(requiredTypeValidator);

            this.gcMultiRow1.Template = template;
            label.Text = "The RequiredTypeValidator's RequiredType is decimal type, by default, the cell's value is 'I'm a 
string type', if you enter edit mode and input a value, then press ESC to escape edit mode to trigger validation 
(DoActionReason is CancelEdit), the old default value is validated, it is not a Decimal type value, so validation fails.";
        }
Private Sub setRequiredTypeValidator_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
setRequiredTypeValidator.Click
        Dim template As Template = template.CreateGridTemplate(1)

        Dim requiredTypeValidator As New RequiredTypeValidator()
        requiredTypeValidator.RequiredType = GetType(Decimal)

        Dim tipNotify As New TipNotify()
        tipNotify.ToolTipIcon = ToolTipIcon.Warning
        tipNotify.ToolTipSpan = 6000
        tipNotify.ToolTipTitle = "Requird Type Error"
        tipNotify.ToolTipText = "The original value is not Decimal type"
        'When you escape edit mode, the action is done (press ESC key)
        tipNotify.DoActionReason = ValidateReasons.CancelEdit
        requiredTypeValidator.Actions.Add(tipNotify)

        'When cancel edit, this value is validated.
        template.Row.Cells(0).Value = "I'm string type"
        template.Row.Cells(0).Validators.Add(requiredTypeValidator)

        Me.gcMultiRow1.Template = template
        label.Text = "The RequiredTypeValidator's RequiredType is decimal type, by default, the cell's value is 'I'm string 
type', if you enter edit mode and input a value, then press ESC to escape edit mode to trigger validation 
(DoActionReason is CancelEdit), the old default value is validated, it is not a Decimal type value, so validation fails."
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RequiredTypeValidator Class
RequiredTypeValidator Members

 

 


Copyright © GrapeCity, inc. All rights reserved.