PropertyGrid.BrowsableAttributes fails when adding more than one a

  • Thread starter Thread starter kevin
  • Start date Start date
K

kevin

Hey all,
I have a class that inherits from control with some custom properties added,
and I am using a propertygrid to change the properties at run time. I don't
want any of the inherited properties of the control available in the PG so to
each of my class properties I amassigning a CategoryAttribute and I am adding
the same categories to the PG.BrowsableAttributes collection. When I add a
single category to the BrowsableAttributes collection it works fine, but when
I add more than one, none of the categories show up in the PG. I am wonding
if there is a simple setting in the PG, or if I have missed something setting
it all up.... any ideas?
thanks

my test code

Option Strict On
Option Explicit On
Imports System.ComponentModel

Module Consts
Public Const DESCRIPTION_CATEGORY As String = "Description Category"
Public Const OTHER_CATEGORY As String = "Other Category"
End Module

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim attrb1 As New CategoryAttribute(DESCRIPTION_CATEGORY)
Dim attrb2 As New CategoryAttribute(OTHER_CATEGORY)
Dim attributes As AttributeCollection

'THIS WORKS -show the description category
attributes = New AttributeCollection(New CategoryAttribute() {attrb1})

'THIS WORKS -shows the other category
attributes = New AttributeCollection(New CategoryAttribute() {attrb2})

'THIS FAILS - shows neither category
attributes = New AttributeCollection(New CategoryAttribute()
{attrb1, attrb2})

Me.PropertyGrid1.BrowsableAttributes = attributes


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim myCls As New MyClassDefinition
Me.PropertyGrid1.SelectedObject = myCls

End Sub
End Class


Public Class MyClassDefinition
Inherits Control
Private _Description As String
<CategoryAttribute(DESCRIPTION_CATEGORY), _
Browsable(True), _
[ReadOnly](False), _
DescriptionAttribute("This Object's description")> _
Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal value As String)
_Description = value
End Set
End Property

Private _Other As String
<CategoryAttribute(OTHER_CATEGORY), _
Browsable(True), _
[ReadOnly](False), _
DescriptionAttribute("This Object's other stuff")> _
Public Property Other() As String
Get
Return _Other
End Get
Set(ByVal value As String)
_Other = value

End Set
End Property


End Class
 
Back
Top