全局代码,要设置什么属性,在这里面设置
Public Class Demo
#Region "Private Variables "
Private bLocked As Boolean = True
Private dtCreateDate As Date
Private strFilePath As String
Private strFolderPath As String
#End Region
#Region "Public Properties"
Public Property Locked() As Boolean
Get
Return bLocked
End Get
Set(ByVal value As Boolean)
bLocked = value
End Set
End Property
Public Property CreatDate() As Date
Get
Return dtCreateDate
End Get
Set(ByVal value As Date)
dtCreateDate = value
End Set
End Property
Public Property FilePath() As String
Get
Return strFilePath
End Get
Set(ByVal value As String)
strFilePath = value
End Set
End Property
Public Property FolderPath() As String
Get
Return strFolderPath
End Get
Set(ByVal value As String)
strFolderPath = value
End Set
End Property
#End Region
End Class
调用代码
Dim pgd As New Windows.Forms.PropertyGrid
Dim d As new Demo
pgd.SelectedObject = d
e.Form.Controls("Panel1").BaseControl.Controls.Add(pgd)
参考 http://blog.csdn.net/naive1010/article/details/1745047