Problem when setting the ReadOnly state of a property: CLOSED
-
Aaaaaaaaaaaaaaaaaarg! As usual once I post I figure it out. The PropertyGrid does not maintain the state. It has to be reloaded. How Dumb. Sorry Hello all, I have a problem where the PropertyGrid does not update a property when changing a property to ReadOnly and not ReadOnly. The problem occurs when I have 2 controls of the 'same type'. Below is test code which contains all of the things I have tried to refresh the PropertyGrid with no success. When Control1 is loaded into the PropertyGrid I change the DesignLocked state and update the ReadOnly state of the PostPrintString to Readonly or not ReadOnly depending on the DesignLocked Value. This works in Control1. However, after I have changed the value in Control1 and then select Control2 into the PropertyGrid (through a button click in MainForm), the PostPrintString property in the grid maintains the same ReadOnly state of Control1. I've tried a number of things I've seen on google including NotifyParentPropertyAttribute with no success. I would appreciate any help with this. Thank you This is the test code in MainForm to load each control. Private Sub Ctrl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctrl1.Click Me.PropertyGrid1.SelectedObject = Nothing Me.PropertyGrid1.Refresh() Me.PropertyGrid1.SelectedObject = Me.ctrl1 Me.PropertyGrid1.Refresh() End Sub Private Sub Ctrl2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctrl2.Click Me.PropertyGrid1.SelectedObject = Nothing Me.PropertyGrid1.Refresh() Me.PropertyGrid1.SelectedObject = Me.ctrl2 Me.PropertyGrid1.Refresh() End Sub Below is the test code in a UserControl that shows what I do when I change the DesignLocked property. Imports System.ComponentModel Imports System.Reflection Public Class TestUserControl ' Gets loaded with MainForms PropertyGrid Public _PropertyGrid As PropertyGrid _ Public Property PostPrintString() As String Get Return "" End Get Set(ByVal value As String) End Set End Property ''' ''' Get