Results 1 to 1 of 1

Thread: [2008] Collection Editor Problem!

Threaded View

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    [2008] Collection Editor Problem!

    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:
    1. Public Class ElementArrayEditor
    2.     Inherits System.ComponentModel.Design.ArrayEditor
    3.  
    4. #Region " Methods "
    5.  
    6.     Sub New(ByVal arrayType As Type)
    7.         MyBase.New(arrayType)
    8.     End Sub
    9.  
    10.     Protected Overrides Function CreateCollectionForm() As System.ComponentModel.Design.CollectionEditor.CollectionForm
    11.         Dim form As System.ComponentModel.Design.CollectionEditor.CollectionForm = MyBase.CreateCollectionForm()
    12.         form.StartPosition = FormStartPosition.CenterParent
    13.         Dim ctrl As Control = form.Controls("overArchingTableLayoutPanel")
    14.         ' Disables Add/Remove buttons
    15.         ctrl.Controls("addRemoveTableLayoutPanel").Enabled = False
    16.  
    17.         ' Get a reference to the private fieldtype propertyBrowser
    18.         ' This is the propertgrid inside the collectionform
    19.         Dim fInfo As FieldInfo = form.GetType.GetField("propertyBrowser", BindingFlags.NonPublic Or BindingFlags.Instance)
    20.         If fInfo IsNot Nothing Then
    21.             ' get a reference to the propertygrid instance located on the form
    22.             Dim pGrid As PropertyGrid = CType(fInfo.GetValue(form), PropertyGrid)
    23.             If pGrid IsNot Nothing Then
    24.                 ' Make the help/description visible
    25.                 pGrid.HelpVisible = True
    26.             End If
    27.         End If
    28.         Return form
    29.     End Function
    30.  
    31.     Protected Overrides Function CanSelectMultipleInstances() As Boolean
    32.         Return True
    33.     End Function
    34.  
    35. #End Region
    36.  
    37. End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width