Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
HINWEIS: Diese Klasse ist mittlerweile veraltet. Die nicht veraltete Alternative ist SettingsBindableAttribute.
Gibt an, dass die Eigenschaft als Anwendungseinstellung verwendet werden kann.
Namespace: System.ComponentModel
Assembly: System (in system.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Property)> _
<ObsoleteAttribute("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")> _
Public Class RecommendedAsConfigurableAttribute
Inherits Attribute
'Usage
Dim instance As RecommendedAsConfigurableAttribute
[AttributeUsageAttribute(AttributeTargets.Property)]
[ObsoleteAttribute("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")]
public class RecommendedAsConfigurableAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)]
[ObsoleteAttribute(L"Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")]
public ref class RecommendedAsConfigurableAttribute : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property) */
/** @attribute ObsoleteAttribute("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.") */
public class RecommendedAsConfigurableAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Property)
ObsoleteAttribute("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")
public class RecommendedAsConfigurableAttribute extends Attribute
Hinweise
Eigenschaften, die mit dem RecommendedAsConfigurableAttribute mit dem Wert true markiert sind, werden angezeigt, wenn Sie im Eigenschaftenfenster die Zeile ConfigurableProperties erweitern. Eine Eigenschaft, für die keine empfohlene Einstellung vorhanden ist oder die mit RecommendedAsConfigurableAttribute mit dem Wert false markiert ist, wird nicht angezeigt und ist als Anwendungseinstellung ungeeignet. Der Standardwert ist false.
Sie können eine Eigenschaft, die nicht über ein RecommendedAsConfigurableAttribute verfügt, an eine Einstellung in Visual Studio .NET binden, indem Sie im Eigenschaftenfenster unter Einstellungen auf die Auslassungszeichen (...) klicken und die entsprechende Eigenschaft in der Liste auswählen.
Hinweis
Wenn Sie eine Eigenschaft mit RecommendedAsConfigurableAttribute mit dem Wert true markieren, wird der Wert dieses Attributs auf den konstanten Member Yes festgelegt. Für eine mit RecommendedAsConfigurableAttribute mit dem Wert false markierte Eigenschaft ist der Wert No. Wenn Sie den Wert dieses Attributs im Code überprüfen möchten, müssen Sie deshalb das Attribut als RecommendedAsConfigurableAttribute.Yes oder RecommendedAsConfigurableAttribute.No angeben.
Weitere Informationen finden Sie unter Übersicht über Attribute und Erweitern von Metadaten mithilfe von Attributen.
.
Beispiel
Im folgenden Beispiel wird eine Eigenschaft so markiert, dass sie als Anwendungseinstellung verwendet werden kann.
<RecommendedAsConfigurable(True)> _
Public Property MyProperty() As Integer
Get
' Insert code here.
Return 0
End Get
Set
' Insert code here.
End Set
End Property
[RecommendedAsConfigurable(true)]
public int MyProperty {
get {
// Insert code here.
return 0;
}
set {
// Insert code here.
}
}
public:
[RecommendedAsConfigurable(true)]
property int MyProperty
{
int get()
{
// Insert code here.
return 0;
}
void set( int /*value*/ )
{
// Insert code here.
}
}
/** @attribute RecommendedAsConfigurable(true)
*/
/** @property
*/
public int get_MyProperty()
{
// Insert code here.
return 0;
} //get_MyProperty
/** @property
*/
public void set_MyProperty(int value)
{
// Insert code here.
} //set_MyProperty
Im folgenden Beispiel wird veranschaulicht, wie der Wert von RecommendedAsConfigurableAttribute für MyProperty überprüft wird. Zunächst wird im Code eine PropertyDescriptorCollection mit allen Eigenschaften für das Objekt abgerufen. Anschließend wird MyProperty über den Index in PropertyDescriptorCollection abgerufen. Die Attribute für diese Eigenschaft werden zurückgegeben und in der Variablen attributes gespeichert.
In diesem Beispiel werden zwei verschiedene Möglichkeiten zum Überprüfen des Werts von RecommendedAsConfigurableAttribute gezeigt. Im zweiten Codefragment wird die Equals-Methode aufgerufen. Im letzten Codefragment wird der Wert anhand der RecommendedAsConfigurable-Eigenschaft überprüft.
' Gets the attributes for the property.
Dim attributes As AttributeCollection = TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
' Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
If attributes(GetType(RecommendedAsConfigurableAttribute)).Equals(RecommendedAsConfigurableAttribute.Yes) Then
' Insert code here.
End If
' This is another way to see if the property is recommended as configurable.
Dim myAttribute As RecommendedAsConfigurableAttribute = _
CType(attributes(GetType(RecommendedAsConfigurableAttribute)), RecommendedAsConfigurableAttribute)
If myAttribute.RecommendedAsConfigurable Then
' Insert code here.
End If
// Gets the attributes for the property.
AttributeCollection attributes =
TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
// Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
if(attributes[typeof(RecommendedAsConfigurableAttribute)].Equals(RecommendedAsConfigurableAttribute.Yes)) {
// Insert code here.
}
// This is another way to see if the property is recommended as configurable.
RecommendedAsConfigurableAttribute myAttribute =
(RecommendedAsConfigurableAttribute)attributes[typeof(RecommendedAsConfigurableAttribute)];
if(myAttribute.RecommendedAsConfigurable) {
// Insert code here.
}
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;
// Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
if ( attributes[ RecommendedAsConfigurableAttribute::typeid ]->Equals( RecommendedAsConfigurableAttribute::Yes ) )
{
// Insert code here.
}
// This is another way to see if the property is recommended as configurable.
RecommendedAsConfigurableAttribute^ myAttribute = dynamic_cast<RecommendedAsConfigurableAttribute^>(attributes[ RecommendedAsConfigurableAttribute::typeid ]);
if ( myAttribute->RecommendedAsConfigurable )
{
// Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes =
TypeDescriptor.GetProperties(this).get_Item(
"MyProperty").get_Attributes();
// Checks to see if the value of the
// RecommendedAsConfigurableAttribute is Yes.
if (attributes.get_Item(RecommendedAsConfigurableAttribute.class.
ToType()).Equals(RecommendedAsConfigurableAttribute.Yes)) {
// Insert code here.
}
// This is another way to see if the property is recommended
// as configurable.
RecommendedAsConfigurableAttribute myAttribute =
((RecommendedAsConfigurableAttribute)(attributes.get_Item
(RecommendedAsConfigurableAttribute.class.ToType())));
if (myAttribute.get_RecommendedAsConfigurable()) {
// Insert code here.
}
Verwenden Sie zur Prüfung folgenden Code, wenn Sie eine Klasse mit dem RecommendedAsConfigurableAttribute markiert haben.
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(RecommendedAsConfigurableAttribute)).Equals(RecommendedAsConfigurableAttribute.Yes) Then
' Insert code here.
End If
AttributeCollection attributes =
TypeDescriptor.GetAttributes(MyProperty);
if(attributes[typeof(RecommendedAsConfigurableAttribute)].Equals(RecommendedAsConfigurableAttribute.Yes)) {
// Insert code here.
}
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ RecommendedAsConfigurableAttribute::typeid ]->Equals( RecommendedAsConfigurableAttribute::Yes ) )
{
// Insert code here.
}
AttributeCollection attributes =
TypeDescriptor.GetAttributes("MyProperty");
if (attributes.get_Item(RecommendedAsConfigurableAttribute.class.
ToType()).Equals(RecommendedAsConfigurableAttribute.Yes)) {
// Insert code here.
}
Vererbungshierarchie
System.Object
System.Attribute
System.ComponentModel.RecommendedAsConfigurableAttribute
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 1.0, 1.1
Veraltet (Compilerwarnung) in 2.0
Siehe auch
Referenz
RecommendedAsConfigurableAttribute-Member
System.ComponentModel-Namespace
Attribute
PropertyDescriptor-Klasse
AttributeCollection-Klasse
PropertyDescriptorCollection-Klasse