Welcome to the Xceed Community | Help
Community Search  
More Search Options

Validating event is not raised

Sort Posts: Previous Next
  •  04-29-2009, 9:54 AM Post no. 20627

    Validating event is not raised

    Hello,

     I have a column which I would like to validate with custom validation rule. I've found EventCellValidationRule class in documentation and created a derieved class:

         public class AttributeValueValidationRule : EventCellValidationRule

        {

            public override ValidationResult Validate(object value, CultureInfo cultureInfo,

                                                     CellValidationContext cellValidationContext)

            {

    //some validation code

            }

        } 

     

     Also I've added this class to column's CellValidationRules collection and created handler for Validating event:

                         <xcdg:Column FieldName="Value" Title="Value" CellEditor="{x:Static xcdg:CellEditor.TextBoxEditor}">

                            <xcdg:Column.CellValidationRules>

                                <local:AttributeValueValidationRule Validating="AttributeValueValidationRule_Validating"/>

                            </xcdg:Column.CellValidationRules>

                        </xcdg:Column>                    

             private void AttributeValueValidationRule_Validating(object sender, CellValidatingEventArgs e)

            {

    //some code here

            } 

    But it seems that Validating event is never raised. Or it does not work this way? Could you please tell me what am I doing wrong?

     

    Thanks,

    Igor 

    Filed under:
  •  04-30-2009, 4:31 PM Post no. 20658 in reply to 20627

    Re: Validating event is not raised

    Hi Igor,

    You have probably forgotten to call the Validate method on base in the Override of the Validate method of your derived class.

    Update your code as follow to make it work:

     

    public class AttributeValueValidationRule : EventCellValidationRule

      {

        public override ValidationResult Validate( object value, CultureInfo cultureInfo,CellValidationContext cellValidationContext )

        {

          //some validation code

          //you must call the base method in order to call the validating event handler

          base.Validate( value, cultureInfo, cellValidationContext );

          return ValidationResult.ValidResult;

        }

      }

     

    And

     

    private void AttributeValueValidationRule_Validating( object sender, CellValidatingEventArgs e )

        {

     

          //some code here

          object o = e.Value;

     

        }

     


    Xceed - Software Developer and Technical Support
  •  05-04-2009, 6:16 AM Post no. 20689 in reply to 20658

    Re: Validating event is not raised

    Hi Mohamed,

      Thanks a lot, now it works. But it seems that Validating event is supposed to be raised only if validation succeeds. Am I right?

     Igor 

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.