Spread Windows Forms 13.0 Product Documentation
Spread Windows Forms 13.0 Product Documentation / Developer's Guide / Customizing Interaction in Cells / Using Validation in Cells / Using a Character Format Validator
In This Topic
    Using a Character Format Validator
    In This Topic

    You can create a validator that checks for specific characters.

    A validation error occurs if the value is not valid. You can also create an action, such as adding a backcolor to the cell, that lets the user know the value is invalid.

    Use the CharFormatValidator class to create the validator. Specify a notification type such as CellStyleNotify. Then use the AddValidators method to add the validator to a cell range.

    The following image displays an invalid backcolor for the cell.

    Using Code

    The following example displays an invalid backcolor if you type characters other than the format string.

    Copy Code
    FarPoint.Win.Spread.CellStyleNotify cnotify = new FarPoint.Win.Spread.CellStyleNotify();
    cnotify.InvalidCellStyle.BackColor = Color.Aqua;
    FarPoint.Win.Spread.CharFormatValidator cFormatValidator1 = new FarPoint.Win.Spread.CharFormatValidator();
    cFormatValidator1.Format = "Aa";
    fpSpread1.Sheets[0].AddValidators(new FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), cFormatValidator1);
    Copy Code
    Dim cnotify As New FarPoint.Win.Spread.CellStyleNotify()
    cnotify.InvalidCellStyle.BackColor = Color.Aqua
    Dim charFormatValidator1 As New FarPoint.Win.Spread.CharFormatValidator()
    charFormatValidator1.Format = "Aa"
    fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), charFormatValidator1)