GrapeCity MultiRow Windows Forms Documentation
ErrorText Property (Cell)
Example 


Gets or sets the text describing an error condition associated with the cell.
Syntax
<BrowsableAttribute(False)>
<DefaultValueAttribute()>
Public Property ErrorText As String
Dim instance As Cell
Dim value As String
 
instance.ErrorText = value
 
value = instance.ErrorText
[Browsable(false)]
[DefaultValue()]
public string ErrorText {get; set;}

Property Value

A System.String value that represents the text describing an error condition associated with the cell. The default is String.Empty.
Remarks
Typically, the ErrorText property is used when handling the GcMultiRow.CellValidating event of the GcMultiRow control. If the cell's value fails some validation criteria, set the ErrorText property and cancel the commit operation by setting the Cancel property of the CellValidatingEventArgs to true. The text you specify is then displayed by GcMultiRow, and the user is prompted to fix the error in the cell's data. When the GcMultiRow.VirtualMode property of the GcMultiRow control is true, you can provide error text for rows and cells using the GcMultiRow.RowErrorTextNeeded and GcMultiRow.CellErrorTextNeeded events. When you assign a different ErrorText string to a cell, the GcMultiRow.CellErrorTextChanged event of the GcMultiRow control occurs.
Example
The following code example shows how to use this property to notify the user of a cell value error. To run this example, create a windows form, and add a GcMultiRow control to the form. Add a NumericUpDownCell named "Age" to the MultiRow controls template. Add the event handle of this event and copy the following code into the event handler. Input an invalid value and try to leave the cell.
void gcMultiRow1_CellValidating(object sender, CellValidatingEventArgs e)
       {
           if (e.CellName == "Age")
           {
               int age = int.Parse(e.FormattedValue.ToString());
               if (age < 0 || age > 100)
               {
                   e.Cancel = true;

                   // Set error text to why the cell validating failed.
                   this.gcMultiRow1[e.RowIndex, e.CellIndex].ErrorText = "The age should be greater than 0 and less than 100.";

                   this.gcMultiRow1.EndEdit();
               }
               else
               {
                   this.gcMultiRow1[e.RowIndex, e.CellIndex].ErrorText = string.Empty;
               }
           }
       }
Private Sub gcMultiRow1_CellValidating(ByVal sender As Object, ByVal e As CellValidatingEventArgs) Handles gcMultiRow1.CellValidating
        If e.CellName = "Age" Then
            Dim age As Integer = Integer.Parse(e.FormattedValue.ToString())
            If age < 0 OrElse age > 100 Then
                e.Cancel = True

                ' Set error text to why the cell validating failed.
                Me.gcMultiRow1(e.RowIndex, e.CellIndex).ErrorText = "The age should greater than 0 and less than 100."

                Me.gcMultiRow1.EndEdit()
            Else
                Me.gcMultiRow1(e.RowIndex, e.CellIndex).ErrorText = String.Empty
            End If
        End If
    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

Cell Class
Cell Members
ErrorIcon Property
ErrorIconAlignment Property

 

 


Copyright © GrapeCity, inc. All rights reserved.