コード例 #1
0
        protected override bool SetValue(int rowIndex, object value)
        {
            bool changed = (base.GetValue(rowIndex) != null && value != null) && base.GetValue(rowIndex).ToString().Equals(value) == false;
            PropertyGridValidateResult validateResult = this.Owner.ValidateValue(this.OwnerRow.PropertyName, value, changed);

            if (validateResult.Success == false)
            {
                this.ErrorText = validateResult.Message;
                return(false);
            }
            return(base.SetValue(rowIndex, value));
        }
コード例 #2
0
 protected override bool SetValue(int rowIndex, object value)
 {
     if (this.DataGridView != null && ((PropertyGridDataGridView)this.DataGridView).SelectedObjectSeting == false)
     {
         PropertyTextBoxEditorAttribute editorAttribute = (PropertyTextBoxEditorAttribute)this.PropertyEditorAttribute;
         if (value == null || value.ToString() == String.Empty)
         {
             if (editorAttribute.AllowEmpty == false)
             {
                 this.ErrorText = Language.Current.PropertyGrid_ErrorText_NullValueInefficacy;
                 return(false);
             }
             return(base.SetValue(rowIndex, value));
         }
         try
         {
             Convert.ChangeType(value, editorAttribute.TypeCode);
         }
         catch (Exception ex)
         {
             this.ErrorText = ex.Message;
             return(false);
         }
         if (String.IsNullOrEmpty(editorAttribute.Regex) == false)
         {
             if (value != null)
             {
                 Regex r = new Regex(editorAttribute.Regex, RegexOptions.Singleline);
                 Match m = r.Match(value.ToString());
                 if (m.Success == false)
                 {
                     this.ErrorText = editorAttribute.RegexMsg;
                     return(false);
                 }
             }
         }
         bool changed = (base.GetValue(rowIndex) != null && value != null) && base.GetValue(rowIndex).ToString().Equals(value) == false;
         PropertyGridValidateResult validateResult = this.Owner.ValidateValue(this.OwnerRow.PropertyName, value, changed);
         if (validateResult.Success == false)
         {
             this.ErrorText = validateResult.Message;
             return(false);
         }
     }
     return(base.SetValue(rowIndex, value));
 }