private void control_Validated(object sender, EventArgs e) { Control index = sender as Control; if (index == null || this.CurrentObject == null) { return; } DataLayoutValidationInfo layoutValidationInfo = this.validationInfoForEachEditor[index]; if (this.ErrorIcon != null) { layoutValidationInfo.ErrorProvider.Icon = this.GetErrorIcon(); } this.OnItemValidated((object)index, new DataLayoutItemValidatedEventArgs(layoutValidationInfo.Item, layoutValidationInfo.ErrorProvider, layoutValidationInfo.RangeAttribute)); }
protected internal virtual void CreateEditors() { if (this.propertyDescriptorCollection == null) { return; } foreach (PropertyDescriptor propertyDescriptor in this.propertyDescriptorCollection) { if (propertyDescriptor.IsBrowsable && !(propertyDescriptor.GetType().Name == "DataRelationPropertyDescriptor")) { RadRangeAttribute radRangeAttribute = (RadRangeAttribute)null; foreach (Attribute attribute in propertyDescriptor.Attributes) { if (attribute is RadRangeAttribute) { radRangeAttribute = attribute as RadRangeAttribute; } } string str = !(propertyDescriptor.Name != propertyDescriptor.DisplayName) || propertyDescriptor.DisplayName.Length <= 0 ? propertyDescriptor.Name : propertyDescriptor.DisplayName; if (!this.IsPropertyAlreadyCreated(str, propertyDescriptor)) { System.Type suggestedEditorType = this.GetSuggestedEditorType(propertyDescriptor.PropertyType); Control control = this.CreateControl(propertyDescriptor, suggestedEditorType); if (control != null) { control.Validating += new CancelEventHandler(this.control_Validating); control.Validated += new EventHandler(this.control_Validated); ErrorProvider errorProvider = new ErrorProvider(); errorProvider.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); errorProvider.SetIconPadding(control, 2); errorProvider.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError; DataLayoutValidationInfo layoutValidationInfo = new DataLayoutValidationInfo(); layoutValidationInfo.RangeAttribute = radRangeAttribute; layoutValidationInfo.ErrorProvider = errorProvider; if (!this.validationInfoForEachEditor.ContainsKey(control)) { this.validationInfoForEachEditor.Add(control, layoutValidationInfo); } if (!this.editableProperties.ContainsKey(str)) { this.editableProperties.Add(str, control); } } } } } }
public void SubscribeControl(DataLayoutControlItem item, PropertyDescriptor property) { if (item == null || item.AssociatedControl == null) { return; } RadRangeAttribute radRangeAttribute = (RadRangeAttribute)null; foreach (Attribute attribute in property.Attributes) { if (attribute is RadRangeAttribute) { radRangeAttribute = attribute as RadRangeAttribute; } } Control associatedControl = item.AssociatedControl; associatedControl.Validating -= new CancelEventHandler(this.control_Validating); associatedControl.Validated -= new EventHandler(this.control_Validated); associatedControl.Validating += new CancelEventHandler(this.control_Validating); associatedControl.Validated += new EventHandler(this.control_Validated); ErrorProvider errorProvider = new ErrorProvider(); errorProvider.SetIconAlignment(associatedControl, ErrorIconAlignment.MiddleRight); errorProvider.SetIconPadding(associatedControl, 2); errorProvider.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError; DataLayoutValidationInfo layoutValidationInfo = new DataLayoutValidationInfo(); layoutValidationInfo.RangeAttribute = radRangeAttribute; layoutValidationInfo.ErrorProvider = errorProvider; layoutValidationInfo.Item = item; if (this.validationInfoForEachEditor.ContainsKey(associatedControl)) { this.validationInfoForEachEditor[associatedControl].ErrorProvider.Dispose(); this.validationInfoForEachEditor.Remove(associatedControl); } if (this.validationInfoForEachEditor.ContainsKey(associatedControl)) { return; } this.validationInfoForEachEditor.Add(associatedControl, layoutValidationInfo); }