User Control Point Array Property

ShootingStar

Member
Joined
Jul 8, 2005
Messages
5
Programming Experience
3-5
I have a user control which has a property that is an array/collection of points

I am trying to add some default values to a number of points using the DefaultValue decoration from the ComponentModel

e.g.

VB.NET:
Imports System.ComponentModel

Public Class HomewarePolygon
    Inherits UserControl

    Private _NodeArray() As Point

    <Category("Appearance"), DefaultValue(GetType(Point()), "{New System.Drawing.Point(10, 10), New System.Drawing.Point(10, 100), New System.Drawing.Point(100, 100), New System.Drawing.Point(100, 10)}"), Description("Gets or Sets the nodes of the polygon.")> _
    Public Property NodeArray() As Point()
        Get
            Return _NodeArray
        End Get
        Set(ByVal value() As Point)
            _NodeArray = value
        End Set
    End Property


End Class
However this doesn't work. I don't get any errors. I'm not sure what to enter in the string for the default. I need to specify 4 points(x,y). Any ideas???
 
Hi,

What you are trying to do is not what the 'Default Value' Attribute is really ment for. This attribute will not enter values for you automatically, although that is contrary to what the name suggests. It is actually ment for design time support i.e When you right click on that property and click reset it will default back to the values to have entered in this attribute.
To do what you are asking i would simply enter the values for the array in the constructor of your control.
 
Back
Top