|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
PropertyDescriptor-Klasse
System.ComponentModel.MemberDescriptor
System.ComponentModel.PropertyDescriptor
System.ComponentModel.DependencyPropertyDescriptor
System.ComponentModel.TypeConverter.SimplePropertyDescriptor
Namespace: System.ComponentModel
Assembly: System (in System.dll)
Der PropertyDescriptor-Typ macht die folgenden Member verfügbar.
| Name | Beschreibung | |
|---|---|---|
![]() ![]() | PropertyDescriptor(MemberDescriptor) | |
![]() ![]() | PropertyDescriptor(MemberDescriptor, Attribute[]) | |
![]() ![]() | PropertyDescriptor(String, Attribute[]) |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() | AttributeArray | |
![]() | Attributes | |
![]() | Category | |
![]() ![]() | ComponentType | |
![]() | Converter | |
![]() | Description | |
![]() | DesignTimeOnly | |
![]() ![]() | DisplayName | |
![]() | IsBrowsable | |
![]() | IsLocalizable | |
![]() ![]() | IsReadOnly | |
![]() ![]() | Name | |
![]() ![]() | NameHashCode | |
![]() ![]() | PropertyType | |
![]() | SerializationVisibility | |
![]() ![]() | SupportsChangeEvents |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() | AddValueChanged | |
![]() ![]() | CanResetValue | |
![]() ![]() | CreateAttributeCollection | |
![]() | CreateInstance | |
![]() ![]() | Equals | In XNA Framework 3.0 wird dieser Member von Object geerbt..Equals(Object). |
![]() ![]() | FillAttributes | In XNA Framework 3.0 wird dieser Member von MemberDescriptor geerbt..FillAttributes(IList). |
![]() ![]() | Finalize | |
![]() | GetChildProperties() | |
![]() | GetChildProperties(Attribute[]) | |
![]() | GetChildProperties(Object) | |
![]() | GetChildProperties(Object, Attribute[]) | |
![]() | GetEditor | |
![]() ![]() | GetHashCode | In XNA Framework wird dieser Member von GetHashCode() überschrieben. |
![]() | GetInvocationTarget | |
![]() ![]() | GetType | |
![]() | GetTypeFromName | |
![]() ![]() | GetValue | |
![]() ![]() | GetValueChangedHandler | |
![]() ![]() | MemberwiseClone | |
![]() ![]() | OnValueChanged | |
![]() ![]() | RemoveValueChanged | |
![]() ![]() | ResetValue | |
![]() ![]() | SetValue | |
![]() ![]() | ShouldSerializeValue | |
![]() ![]() | ToString |
Converter enthält die TypeConverter-Klasse für diese Eigenschaft. IsLocalizable gibt an, ob diese Eigenschaft lokalisiert werden soll. GetEditor gibt einen Editor des angegebenen Typs zurück.
ComponentType enthält den Typ der Komponente, an die diese Eigenschaft gebunden ist. IsReadOnly gibt an, ob diese Eigenschaft schreibgeschützt ist. PropertyType ruft den Typ der Eigenschaft ab. CanResetValue gibt an, ob durch das Zurücksetzen der Komponente ihr Wert geändert wird. GetValue gibt den aktuellen Wert der Eigenschaft einer Komponente an. ResetValue setzt den Wert der Komponente für diese Eigenschaft zurück. SetValue legt den Wert der Komponente auf einen anderen Wert fest. ShouldSerializeValue gibt an, ob der Wert dieser Eigenschaft beibehalten werden muss.
Hinweis |
|---|
Das auf diesen Typ oder Member angewendete HostProtectionAttribute-Attribut besitzt den folgenden Resources-Eigenschaftswert: SharedState. Das HostProtectionAttribute hat keine Auswirkungen auf Desktopanwendungen (die normalerweise durch Doppelklicken auf ein Symbol, Eingeben eines Befehls oder einer URL in einem Browser gestartet werden). Weitere Informationen finden Sie unter der HostProtectionAttribute-Klasse oder unter SQL Server-Programmierung und Hostschutzattribute. |
// Creates a new collection and assign it the properties for button1. PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1); // Sets an PropertyDescriptor to the specific property. System.ComponentModel.PropertyDescriptor myProperty = properties.Find("Text", false); // Prints the property and the property description. textBox1.Text = myProperty.DisplayName+ '\n' ; textBox1.Text += myProperty.Description + '\n'; textBox1.Text += myProperty.Category + '\n';
using System; using System.Collections; using System.ComponentModel; using System.Text; namespace ReadOnlyPropertyDescriptorTest { // The SerializeReadOnlyPropertyDescriptor shows how to implement a // custom property descriptor. It provides a read-only wrapper // around the specified PropertyDescriptor. internal sealed class SerializeReadOnlyPropertyDescriptor : PropertyDescriptor { private PropertyDescriptor _pd = null; public SerializeReadOnlyPropertyDescriptor(PropertyDescriptor pd) : base(pd) { this._pd = pd; } public override AttributeCollection Attributes { get { return( AppendAttributeCollection( this._pd.Attributes, ReadOnlyAttribute.Yes) ); } } protected override void FillAttributes(IList attributeList) { attributeList.Add(ReadOnlyAttribute.Yes); } public override Type ComponentType { get { return this._pd.ComponentType; } } // The type converter for this property. // A translator can overwrite with its own converter. public override TypeConverter Converter { get { return this._pd.Converter; } } // Returns the property editor // A translator can overwrite with its own editor. public override object GetEditor(Type editorBaseType) { return this._pd.GetEditor(editorBaseType); } // Specifies the property is read only. public override bool IsReadOnly { get { return true; } } public override Type PropertyType { get { return this._pd.PropertyType; } } public override bool CanResetValue(object component) { return this._pd.CanResetValue(component); } public override object GetValue(object component) { return this._pd.GetValue(component); } public override void ResetValue(object component) { this._pd.ResetValue(component); } public override void SetValue(object component, object val) { this._pd.SetValue(component, val); } // Determines whether a value should be serialized. public override bool ShouldSerializeValue(object component) { bool result = this._pd.ShouldSerializeValue(component); if (!result) { DefaultValueAttribute dva = (DefaultValueAttribute)_pd.Attributes[typeof(DefaultValueAttribute)]; if (dva != null) { result = !Object.Equals(this._pd.GetValue(component), dva.Value); } else { result = true; } } return result; } // The following Utility methods create a new AttributeCollection // by appending the specified attributes to an existing collection. static public AttributeCollection AppendAttributeCollection( AttributeCollection existing, params Attribute[] newAttrs) { return new AttributeCollection(AppendAttributes(existing, newAttrs)); } static public Attribute[] AppendAttributes( AttributeCollection existing, params Attribute[] newAttrs) { if (existing == null) { throw new ArgumentNullException("existing"); } if (newAttrs == null) { newAttrs = new Attribute[0]; } Attribute[] attributes; Attribute[] newArray = new Attribute[existing.Count + newAttrs.Length]; int actualCount = existing.Count; existing.CopyTo(newArray, 0); for (int idx = 0; idx < newAttrs.Length; idx++) { if (newAttrs[idx] == null) { throw new ArgumentNullException("newAttrs"); } // Check if this attribute is already in the existing // array. If it is, replace it. bool match = false; for (int existingIdx = 0; existingIdx < existing.Count; existingIdx++) { if (newArray[existingIdx].TypeId.Equals(newAttrs[idx].TypeId)) { match = true; newArray[existingIdx] = newAttrs[idx]; break; } } if (!match) { newArray[actualCount++] = newAttrs[idx]; } } // If some attributes were collapsed, create a new array. if (actualCount < newArray.Length) { attributes = new Attribute[actualCount]; Array.Copy(newArray, 0, attributes, 0, actualCount); } else { attributes = newArray; } return attributes; } } }
using System; using System.Collections; using System.ComponentModel; using System.Text; using System.Windows.Forms.Design; namespace ReadOnlyPropertyDescriptorTest { class DemoControlDesigner : ControlDesigner { // The PostFilterProperties method replaces the control's // Size property with a read-only Size property by using // the SerializeReadOnlyPropertyDescriptor class. protected override void PostFilterProperties(IDictionary properties) { if (properties.Contains("Size")) { PropertyDescriptor original = properties["Size"] as PropertyDescriptor; SerializeReadOnlyPropertyDescriptor readOnlyDescriptor = new SerializeReadOnlyPropertyDescriptor(original); properties["Size"] = readOnlyDescriptor; } base.PostFilterProperties(properties); } } } ... using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Text; using System.Windows.Forms; using System.Windows.Forms.Design; namespace ReadOnlyPropertyDescriptorTest { [Designer(typeof(DemoControlDesigner))] public class DemoControl : Control { public DemoControl() { } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core-Rolle wird nicht unterstützt), Windows Server 2008 R2 (Server Core-Rolle wird mit SP1 oder höher unterstützt; Itanium wird nicht unterstützt)
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.
