وابسته کردن Property ها به هم

ms_vb

Member
سلام
چطور میشه توی Properties کاری کرد که نمایش بعضی از Property ها وابسته به دیگر Property ها باشه؟
مانندPropertyBinding در(ApplicationSettings) شی TextBox که اگر شما گزینه ای را اضافه کنید در قسمت (ApplicationSettings) اضافه خواهد شد
 

the_king

مدیرکل انجمن
سلام
چطور میشه توی Properties کاری کرد که نمایش بعضی از Property ها وابسته به دیگر Property ها باشه؟
مانندPropertyBinding در(ApplicationSettings) شی TextBox که اگر شما گزینه ای را اضافه کنید در قسمت (ApplicationSettings) اضافه خواهد شد

باید کلاس تون دو Interface رو Implements کنه، IBindableComponent و INotifyPropertyChanged
چیزی شبیه به این :
کد:
Public Class MyComponent
    Inherits Component
    Implements IBindableComponent, INotifyPropertyChanged
    Private mDataBindings As ControlBindingsCollection

    Public Event PropertyChanged(ByVal sender As Object, ByVal e _
        As System.ComponentModel.PropertyChangedEventArgs) _
        Implements INotifyPropertyChanged.PropertyChanged

    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        MyBase.Dispose(disposing)
    End Sub

    Public Sub New()
        mDataBindings = New ControlBindingsCollection(Me)
    End Sub

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) _
    , EditorBrowsable(EditorBrowsableState.Advanced) _
    , Browsable(False)> _
    Public Property BindingContext() As BindingContext Implements IBindableComponent.BindingContext
        Get
            Return mDataBindings.BindableComponent.BindingContext
        End Get
        Set(ByVal value As BindingContext)
            mDataBindings.BindableComponent.BindingContext = value
        End Set
    End Property

    <ParenthesizePropertyName(True) _
    , RefreshProperties(RefreshProperties.All) _
    , DesignerSerializationVisibility(DesignerSerializationVisibility.Content) _
    , Category("Data")> _
    Public ReadOnly Property DataBindings() As ControlBindingsCollection Implements IBindableComponent.DataBindings
        Get
            Return mDataBindings
        End Get
    End Property
End Class
 

جدیدترین ارسال ها

بالا