Working with Validations in Columns

Adding Column Validation

To add any kind of validation to a column, please follow the steps below:

  • Add Aspose.Cells.GridDesktop control to your Form
  • Access any desired Worksheet
  • Add a desired Validation to any column

IMPORTANT: For more information about the types of validation (or validation modes like Is Required Validation, Regular Expressions Validation and Custom Validation) and implementing Custom Validation, please refer to Working with Validations in Worksheets.

Accessing Column Validation

To access a specific column validation, please follow the steps below:

  • Access a desired Worksheet
  • Access a specific column Validation in the Worksheet
  • Edit Validation attributes, if desired
 //Accessing first worksheet of the Grid

Worksheet sheet = gridDesktop1.Worksheets[0];

//Accessing the Validation object applied on a specific column

Validation validation = sheet.Columns[2].Validation;

//Editing the attributes of Validation

validation.IsRequired = true;

validation.RegEx = "";

validation.CustomValidation = null;

Removing Column Validation

To remove a specific column validation from the worksheet, please follow the steps below:

  • Access a desired Worksheet
  • Remove a specific column Validation from the Worksheet
 //Accessing first worksheet of the Grid

Worksheet sheet = gridDesktop1.Worksheets[0];

//Removing the Validation applied on a specific column

sheet.Columns[2].RemoveValidation();