NotifyParentPropertyAttribute(Boolean) NotifyParentPropertyAttribute(Boolean) NotifyParentPropertyAttribute(Boolean) NotifyParentPropertyAttribute(Boolean) Constructor

정의

속성 값의 변경 내용을 부모 속성에 알릴지 여부를 결정하는 지정된 값을 사용하여 NotifyParentPropertyAttribute 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the NotifyParentPropertyAttribute class, using the specified value to determine whether the parent property is notified of changes to the value of the property.

public:
 NotifyParentPropertyAttribute(bool notifyParent);
public NotifyParentPropertyAttribute (bool notifyParent);
new System.ComponentModel.NotifyParentPropertyAttribute : bool -> System.ComponentModel.NotifyParentPropertyAttribute
Public Sub New (notifyParent As Boolean)

매개 변수

notifyParent
Boolean Boolean Boolean Boolean

부모 속성에 변경 내용을 알려야 하면 true이고, 그렇지 않으면 false입니다.true if the parent should be notified of changes; otherwise, false.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 NotifyParentPropertyAttributeExpandableObjectConverter 클래스 사용자 지정 컨트롤에서 확장 가능한 속성을 만들려고 합니다.The following code example demonstrates how to use the NotifyParentPropertyAttribute and the ExpandableObjectConverter class to create an expandable property on a custom control.

[TypeConverter(typeof(BorderAppearanceConverter))]
public class BorderAppearance
{
    private int borderSizeValue = 1;
    private Color borderColorValue = Color.Empty;

    [Browsable(true),
    NotifyParentProperty(true),
    EditorBrowsable(EditorBrowsableState.Always),
    DefaultValue(1)]
    public int BorderSize
    {
        get
        {
            return borderSizeValue;
        }
        set
        {
            if (value < 0)
            {
                throw new ArgumentOutOfRangeException(
                    "BorderSize",
                    value,
                    "must be >= 0");
            }

            if (borderSizeValue != value)
            {
                borderSizeValue = value;
            }
        }
    }

    [Browsable(true)]
    [NotifyParentProperty(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [DefaultValue(typeof(Color), "")]
    public Color BorderColor
    {
        get
        {
            return borderColorValue;
        }
        set
        {
            if (value.Equals(Color.Transparent))
            {
                throw new NotSupportedException("Transparent colors are not supported.");
            }

            if (borderColorValue != value)
            {
                borderColorValue = value;
            }
        }
    }
}
<TypeConverter(GetType(BorderAppearanceConverter))>  _
Public Class BorderAppearance
    Private borderSizeValue As Integer = 1
    Private borderColorValue As Color = Color.Empty
    
    
    <Browsable(True), NotifyParentProperty(True), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(1)>  _
    Public Property BorderSize() As Integer 
        Get
            Return borderSizeValue
        End Get
        Set
            If value < 0 Then
                Throw New ArgumentOutOfRangeException("BorderSize", value, "must be >= 0")
            End If
            
            If borderSizeValue <> value Then
                borderSizeValue = value
            End If
        End Set
    End Property
    
    
    <Browsable(True), NotifyParentProperty(True), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(GetType(Color), "")>  _
    Public Property BorderColor() As Color 
        Get
            Return borderColorValue
        End Get
        Set
            If value.Equals(Color.Transparent) Then
                Throw New NotSupportedException("Transparent colors are not supported.")
            End If
            
            If borderColorValue <> value Then
                borderColorValue = value
            End If
        End Set
    End Property
End Class

적용 대상

추가 정보