自定义属性的颜色属性

时间:2010-08-04 14:45:29

标签: vb.net

我编写了一个自定义属性,并获得了以下Color属性,我希望用户能够在类的属性中指示color属性:

    Private _ColumnColor As System.Drawing.Color
    Public Property ColumnColor() As System.Drawing.Color
        Get
            Return _ColumnColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _ColumnColor = value
        End Set
    End Property

我收到以下错误:

"Property or field 'ColumnColor' does not have a valid attribute type

我该如何解决?

由于

1 个答案:

答案 0 :(得分:0)

我首先将AttributeUsage添加到您的媒体资源

<AttributeUsage(AttributeTargets.Property)> _
Private _ColumnColor As System.Drawing.Color
    Public Property ColumnColor() As System.Drawing.Color
        Get
            Return _ColumnColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _ColumnColor = value
        End Set
    End Property