4

Visual StudioなどのIDEで、System.Windows.Forms.Buttonコントロールのプロパティを表示すると、一連のプロパティを公開するいくつかのプロパティが表示されます。例:FlatAppearance、Font、Location、Marginなど。

カスタムコントロールでも同様のことをしたいと思います。

背後にあるコードが間違っていることは知っていますが、これが私がやろうとしていることの例です。

Public Class StateOfMyCustomControl

    Public Enum EnumVisibility
        Visible
        NonVisible
    End Enum

    Public Enum EnumEventManagement
        Automatic
        Manual
    End Enum

    Private mAssociatedControl As MyCustomControl
    Private mVisibility As EnumVisibility
    Private mEventManagement As EnumEventManagement

    Public Sub New(ByVal AssociatedControl As MyCustomControl)
        mAssociatedControl = AssociatedControl
    End Sub

    Public Property Visibility() As EnumVisibility
        Get
            Return mVisibility
        End Get
        Set(ByVal value As EnumVisibility)

            mVisibility = value

            mAssociatedControl.Visible = False
            If mVisibility = EnumVisibility.Visible Then
                mAssociatedControl.Visible = True
            End If

        End Set
    End Property

    Public Property EventManagement() As EnumEventManagement
        Get
            Return mEventManagement
        End Get
        Set(ByVal value As EnumEventManagement)
            mEventManagement = value
        End Set
    End Property

End Class

Public Class MyCustomControl

    ' ...

    Private mState As StateOfMyCustomControl

    Public Sub New()
        mState = New StateOfMyCustomControl(Me)
    End Sub

    Public Property State() As StateOfMyCustomControl
        Get
            Return mState
        End Get
        Set(ByVal value As StateOfMyCustomControl)
            mState = value
        End Set
    End Property

    ' ...

End Class

IDEのカスタムコントロールのプロパティウィンドウで、プロパティの状態を表示し、プロパティの可視性イベント管理を設定するために表示することができます。

どうもありがとう

4

1 に答える 1

3

ExpandableObjectConverterに(またはカスタムコンバーター)を使用するように指示する必要がありますStateOfMyCustomControl。C#では、これは次のとおりです。

[TypeConverter(typeof(ExpandableObjectConverter))]
public class StateOfMyCustomControl {...}

ただし、VBで属性を適用する場合は、それを実行してください; -p

おそらく:

<TypeConverter(GetType(ExpandableObjectConverter))> _
Public Class StateOfMyCustomControl
...
于 2009-04-16T10:27:56.867 に答える