GrapeCity MultiRow Windows Forms Documentation
Notification using CellStyle (CellStyleNotify)

You can use the CellStyleNotify object to change the cell style to notify users of a validation error. For example, you can change the background color or foreground color of the cell to red.

Using Designer

Use the following steps to use CellStyleNotify for notification.

  1. Select a cell for which to validate the value (for example, textBoxCell1).
  2. From the Properties window, select Validators property and click the ... button.
  3. From the displayed CellValidator collection editor, select RequiredFieldValidator from the top-left combo box and click the Add button.
  4. Select the Actions property from the property grid at the right of screen and click the ... button.
  5. Add CellStyleNotify in the displayed CellValidateAction collection editor.
  6. From the Members list, confirm that CellStyleNotify has been selected. From the property grid at the right of screen, set any style in the InvalidCellStyle property (for example, set the BackColor property to Red).
  7. Click the OK button and close the CellValidateAction collection editor.
  8. Click the OK button and close the CellValidator collection editor.
  9. Change the document window tab of the designer to Runtime.
  10. Move to the next cell without making any changes in your selected cell and you can confirm that the validation notification appears.

Using Code

The following code changes the background color of a cell to indicate a validation error when the textBoxCell is blank.

[VB]

Imports GrapeCity.Win.MultiRow

Dim textBoxCell1 As New TextBoxCell()
Dim requiredFieldValidator1 As New RequiredFieldValidator()
Dim cellStyleNotify1 As New CellStyleNotify()
cellStyleNotify1.InvalidCellStyle.BackColor = Color.Red
requiredFieldValidator1.Actions.Add(cellStyleNotify1)
textBoxCell1.Validators.Add(requiredFieldValidator1)

Dim cells As Cell() = {textBoxCell1}
GcMultiRow1.Template = Template.CreateGridTemplate(cells)
GcMultiRow1.RowCount = 10

[CS]

using GrapeCity.Win.MultiRow;

TextBoxCell textBoxCell1 = new TextBoxCell();
RequiredFieldValidator requiredFieldValidator1 = new RequiredFieldValidator();
CellStyleNotify cellStyleNotify1 = new CellStyleNotify();
cellStyleNotify1.InvalidCellStyle.BackColor = Color.Red;
requiredFieldValidator1.Actions.Add(tipNotify1);
textBoxCell1.Validators.Add(requiredFieldValidator1);

Cell[] cells = { textBoxCell1 };
gcMultiRow1.Template = Template.CreateGridTemplate(cells);
gcMultiRow1.RowCount = 10;
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options