GrapeCity MultiRow Windows Forms Documentation
Notification using Message Box (MessageBoxNotify)

You can use the MessageBoxNotify class to notify the user of a validation error by displaying a message box. You can change the title, text, and icon of the message box.

The only button in the message box that is displayed by MessageBoxNotify is the OK button.

Using the Designer

Use the following steps to use a message box for cell validation.

  1. Select a cell value to validate (for example, textBoxCell1).
  2. From the Properties window, select the Validators property and click the ... button.
  3. From the displayed CellValidator collection editor, select RequiredFieldValidator from the left-top combo box and click the Add button.
  4. Select the Actions property from the property grid and click the ... button.
  5. Add MessageBoxNotify in the displayed CellValidateAction collection editor.
  6. From the Members list, confirm that MessageBoxNotify has been selected.
  7. Select the Caption property from the property grid and enter the title.
  8. Set the DoActionReason property in the property grid to CellValidating.
  9. Set the Icon property in the property grid to Hand.
  10. Select the Message property from the property grid and type the description.
  11. Click the OK button to close the CellValidateAction collection editor.
  12. Click the OK button to close the CellValidator collection editor.
  13. Change the document window tab of the designer to Runtime.
  14. Confirm that the validation error is displayed when you move to the next cell without making changes in textBoxCell1.

Using Code

The following code displays the validation error in a message box when a String type cell value is blank.

[VB]

Imports GrapeCity.Win.MultiRow 
Dim textBoxCell1 As New TextBoxCell() 
Dim requiredFieldValidator1 As New RequiredFieldValidator()
Dim messageBoxNotify1 As New MessageBoxNotify() 
messageBoxNotify1.Caption = "Title" 
messageBoxNotify1.DoActionReason = ValidateReasons.CellValidating
messageBoxNotify1.Icon = MessageBoxIcon.Hand 
messageBoxNotify1.Message = "Error" 
requiredFieldValidator1.Actions.Add(messageBoxNotify1)
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(); 
MessageBoxNotify messageBoxNotify1 = new MessageBoxNotify();
messageBoxNotify1.Caption = "Title"; 
messageBoxNotify1.DoActionReason = ValidateReasons.CellValidating; 
messageBoxNotify1.Icon = MessageBoxIcon.Hand;
messageBoxNotify1.Message = "Error"; 
requiredFieldValidator1.Actions.Add(messageBoxNotify1); 
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