Hi everyone,
I have a problem with one of my Control Library projects. The project is an Analog Clock Control. I have created it with a design time support so that the properties can be modified through the designer. Everything goes ok except one thing. The Analog Clock has elements (let say the numeric values 1, 2, 3 to 12) and when I edit their properties at design time with Collection Editor Window and than I click the Cancel button than the next time I want to change any property and hit OK button it doesn’t reflect the changes. Note this only happens when I change a property value and hit Cancel button. If I don’t change any value and hit Cancel it doesn’t give the problem for the next time if I want to change the property. I should specify that this problem is associated with Array of Elements that are shown in Collection Editor. Also I noticed that if I enter invalid value for the property and get the error box telling me that the value is wrong it start behaving the same way as if I changed the property and hit the Cancel button.
Now I can go on explaining the behavior but the bottom line is that all this happens when the Cancel button is hit after a change or an invalid value is entered for the property. I think that in these two cases new instances are created and assigned to the array of Elements so that the event handlers that were added to the previous items are lost and new items don’t have them. This is just what I think and I may be wrong.
What I want is to find detailed information about what happens when the Cancel button is clicked if a property is modified. If I can understand where is the problem, than I can solve it. It might be that I need to add something to my ArrayEditor but so far I don’t now what would that be. I am providing the code for the classes so you can see what should I add or edit. Please feel free to comment and make any suggestions.
Thank you,
VBDT
vb Code:
Public Class ElementArrayEditor Inherits System.ComponentModel.Design.ArrayEditor #Region " Methods " Sub New(ByVal arrayType As Type) MyBase.New(arrayType) End Sub Protected Overrides Function CreateCollectionForm() As System.ComponentModel.Design.CollectionEditor.CollectionForm Dim form As System.ComponentModel.Design.CollectionEditor.CollectionForm = MyBase.CreateCollectionForm() form.StartPosition = FormStartPosition.CenterParent Dim ctrl As Control = form.Controls("overArchingTableLayoutPanel") ' Disables Add/Remove buttons ctrl.Controls("addRemoveTableLayoutPanel").Enabled = False ' Get a reference to the private fieldtype propertyBrowser ' This is the propertgrid inside the collectionform Dim fInfo As FieldInfo = form.GetType.GetField("propertyBrowser", BindingFlags.NonPublic Or BindingFlags.Instance) If fInfo IsNot Nothing Then ' get a reference to the propertygrid instance located on the form Dim pGrid As PropertyGrid = CType(fInfo.GetValue(form), PropertyGrid) If pGrid IsNot Nothing Then ' Make the help/description visible pGrid.HelpVisible = True End If End If Return form End Function Protected Overrides Function CanSelectMultipleInstances() As Boolean Return True End Function #End Region End Class




Reply With Quote