[[VisualBasic.NET]]~ [[オブジェクトプロパティ]]~ [[オブジェクトプロパティのサンプル2]] * 配列型やコレクション型のプロパティを永続化する方法。 [#h5e4ffaf] <Serealizable()>属性や、<DesignerSerializationVisibility()>属性、EditorAttribute()>属性などを使用する。~ この方法で作成したコントロールのプロパティはリソースに値がセットされる。 <Serializable()>Public Class MyProperty Dim strA As String = ”” Dim intB As Integer = 0 Public Property A() As String Get Return strA End Get Set(ByVal Value As String) strA = Value End Set End Property Public Property B() As Integer Get Return intB End Get Set(ByVal Value As Integer) intB = Value End Set End Property End Class Public Class ArrayPropertyEditor Inherits System.ComponentModel.Design.ArrayEditor Sub New() MyBase.New(GetType(cEventProcess)) End Sub Protected Overrides Function CreateCollectionItemType() As System.Type Return GetType(cEventProcess) End Function End Class Public Class MyControl Inherits System.Windows.Forms.UserControl Dim clsArrayProperty As MyProperty() = {New MyProperty} + Windows フォーム デザイナで生成されたコード <System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content), _ System.ComponentModel.EditorAttribute(GetType(ArrayPropertyEditor), GetType(System.Drawing.Design.UITypeEditor))> _ Public Property MyArrayProperty() As MyProperty() Get Return clsArrayProperty End Get Set(ByVal Value As MyProperty()) clsArrayProperty = Value End Set End Property End Class