I have a class that has a readonly collection property - Its a list of extender providers that have been applied to the control.
I've implemented a simple property descriptor for the collection so that the property can be expanded in the property grid to examine each entry.
When I select an extender provider and set it to false, I remove it from the collection. The GetProperties method of the type converter is requeried and the property grid refreshes.
However, when I set an extender provider to true, and thus add it to the collection, GetProperties is not requeried.
Somehow, the property grid is making a distinction between adding to and removing from the collection. Or alternativly, its refreshing when an extender provider is added, but not when one is removed.
How can I get the grid to refresh when I add to the collection?
I've tried INotifyPropertyChanged and (PropertyName)Changed, but with no success.
ETA:
I've knocked together a small sample to demonstate my problem. For brevity, this sample uses an array and will persist, though not correctly. This does not effect the behaviour at design time though:
Public Class MyButton
Inherits Button
Private _Col As String()
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public ReadOnly Property Col() As String()
Get
Return Me._Col
End Get
End Property
Private _AlterCol As String
''''''<RefreshProperties(RefreshProperties.All)> _
Public Property AlterCol() As String
Get
Return _AlterCol
End Get
Set(ByVal value As String)
_AlterCol = value
ReDim Preserve Me._Col(Me._Col.Length)
Me._Col(Me._Col.Length - 1) = value
End Set
End Property
Public Sub New()
ReDim Me._Col(2)
Me._Col(0) = "Fred"
Me._Col(1) = "Jim"
Me._Col(2) = "Bob"
End Sub
End Class
Now, to see the behaviour in action, add a MyButton to a form, expand the Col property and type some text into the AlterCol property.
The expanded sub properties in Col will not change. However, comment out RefreshProperties.All and it will be re-queried and updated.
My problem is that I am not updating Col from a Read/Write property. I'm updating it in response to an external provider being added.
I need to force the property grid to refresh somehow. The only way I can think of doing it is a dummy property, decorated with RefreshProperties, that I assign a changed value to.
Any ideas?