public DataLayoutItemValidatedEventArgs( DataLayoutControlItem item, ErrorProvider errorProvider, RadRangeAttribute rangeAttribute) { this.item = item; this.errorProvider = errorProvider; this.rangeAttribute = rangeAttribute; }
public DataLayoutValidationInfo( DataLayoutControlItem item, ErrorProvider errorProvider, RadRangeAttribute rangeAttribute) { this.item = item; this.errorProvider = errorProvider; this.rangeAttribute = rangeAttribute; }
public ItemValidatingEventArgs( RadLabel label, RadLabel validation, ErrorProvider errorProvider, RadRangeAttribute rangeAttribute) { this.label = label; this.validationLabel = validation; this.errorProvider = errorProvider; this.rangeAttribute = rangeAttribute; }
public ValidationInfo( RadLabel label, RadLabel validationLabel, ErrorProvider errorProvider, RadRangeAttribute rangeAttribute) { this.label = label; this.validationLabel = validationLabel; this.errorProvider = errorProvider; this.rangeAttribute = 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); }
public void SubscribeControl( Control control, PropertyDescriptor property, RadLabel label, RadLabel validationLabel) { RadRangeAttribute radRangeAttribute = (RadRangeAttribute)null; foreach (Attribute attribute in property.Attributes) { if (attribute is RadRangeAttribute) { radRangeAttribute = attribute as RadRangeAttribute; } } control.Validating -= new CancelEventHandler(this.control_Validating); control.Validated -= new EventHandler(this.control_Validated); 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; ValidationInfo validationInfo = new ValidationInfo(); validationInfo.RangeAttribute = radRangeAttribute; validationInfo.ErrorProvider = errorProvider; validationInfo.Label = label; validationInfo.ValidationLabel = validationLabel; if (this.validationInfoForEachEditor.ContainsKey(control)) { this.validationInfoForEachEditor[control].ErrorProvider.Dispose(); this.validationInfoForEachEditor.Remove(control); } if (this.validationInfoForEachEditor.ContainsKey(control)) { return; } this.validationInfoForEachEditor.Add(control, validationInfo); }
private void SetupControlSpecificProperties(Control control, PropertyDescriptor property) { RadDropDownList radDropDownList = control as RadDropDownList; if (radDropDownList != null && property.PropertyType.IsEnum) { foreach (object obj in Enum.GetValues(property.PropertyType)) { RadListDataItem radListDataItem = new RadListDataItem(obj.ToString(), obj); radDropDownList.Items.Add(radListDataItem); } radDropDownList.DropDownStyle = RadDropDownStyle.DropDownList; } RadSpinEditor radSpinEditor = control as RadSpinEditor; if (radSpinEditor == null) { return; } RadRangeAttribute radRangeAttribute = (RadRangeAttribute)null; foreach (Attribute attribute in property.Attributes) { if (attribute is RadRangeAttribute) { radRangeAttribute = attribute as RadRangeAttribute; } } if (radRangeAttribute != null) { radSpinEditor.Minimum = (Decimal)radRangeAttribute.MinValue; radSpinEditor.Maximum = (Decimal)radRangeAttribute.MaxValue; } else { radSpinEditor.Minimum = new Decimal(int.MinValue); radSpinEditor.Maximum = new Decimal(int.MaxValue); } }
protected virtual void SetMinAndMaxValue(PropertyGridItem item) { RadRangeAttribute attribute = item.Attributes[typeof(RadRangeAttribute)] as RadRangeAttribute; if (attribute != null) { this.MinValue = (Decimal)attribute.MinValue; this.MaxValue = (Decimal)attribute.MaxValue; } else { switch (System.Type.GetTypeCode(item.PropertyType)) { case TypeCode.SByte: this.MinValue = new Decimal((int)sbyte.MinValue); this.MaxValue = new Decimal((int)sbyte.MaxValue); break; case TypeCode.Byte: this.MinValue = new Decimal(0); this.MaxValue = new Decimal((int)byte.MaxValue); break; case TypeCode.Int16: this.MinValue = new Decimal((int)short.MinValue); this.MaxValue = new Decimal((int)short.MaxValue); break; case TypeCode.UInt16: this.MinValue = new Decimal(0); this.MaxValue = new Decimal((int)ushort.MaxValue); break; case TypeCode.Int32: this.MinValue = new Decimal(int.MinValue); this.MaxValue = new Decimal(int.MaxValue); break; case TypeCode.UInt32: this.MinValue = new Decimal(0); this.MaxValue = new Decimal((long)uint.MaxValue); break; case TypeCode.Int64: this.MinValue = new Decimal(long.MinValue); this.MaxValue = new Decimal(long.MaxValue); break; case TypeCode.UInt64: this.MinValue = new Decimal(0); this.MaxValue = new Decimal(-1, -1, 0, false, (byte)0); break; case TypeCode.Single: this.MinValue = new Decimal(-1, -1, -1, true, (byte)0); this.MaxValue = new Decimal(-1, -1, -1, false, (byte)0); break; case TypeCode.Double: this.MinValue = new Decimal(-1, -1, -1, true, (byte)0); this.MaxValue = new Decimal(-1, -1, -1, false, (byte)0); break; case TypeCode.Decimal: this.MinValue = new Decimal(-1, -1, -1, true, (byte)0); this.MaxValue = new Decimal(-1, -1, -1, false, (byte)0); break; } } }
protected internal virtual void CreateEditors() { if (this.propertyDescriptorCollection == null) { return; } foreach (PropertyDescriptor propertyDescriptor in this.propertyDescriptorCollection) { if (propertyDescriptor.IsBrowsable && !(propertyDescriptor.GetType().Name == "DataRelationPropertyDescriptor")) { string str = !(propertyDescriptor.Name != propertyDescriptor.DisplayName) || propertyDescriptor.DisplayName.Length <= 0 ? propertyDescriptor.Name : propertyDescriptor.DisplayName; if (!this.IsThisPropertyAlreadyCreated(str, propertyDescriptor)) { Control control; if (propertyDescriptor.PropertyType.IsEnum) { control = this.CreateEnum(propertyDescriptor); } else { switch (propertyDescriptor.PropertyType.Name) { case "DateTime": control = this.CreateDateTime(propertyDescriptor); break; case "Boolean": control = this.CreateBoolean(propertyDescriptor); break; case "Color": control = this.CreateColor(propertyDescriptor); break; case "Image": control = this.CreateImage(propertyDescriptor); break; default: control = this.CreateTextBox(propertyDescriptor); break; } } if (control != null) { control.Dock = DockStyle.Fill; 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; RadRangeAttribute radRangeAttribute = (RadRangeAttribute)null; foreach (Attribute attribute in propertyDescriptor.Attributes) { if (attribute is RadRangeAttribute) { radRangeAttribute = attribute as RadRangeAttribute; } } ValidationInfo validationInfo = new ValidationInfo(); validationInfo.RangeAttribute = radRangeAttribute; validationInfo.ErrorProvider = errorProvider; if (!this.validationInfoForEachEditor.ContainsKey(control)) { this.validationInfoForEachEditor.Add(control, validationInfo); } if (!this.editableProperties.ContainsKey(str)) { this.editableProperties.Add(str, control); } } } } } }