Can't edit items' properties in CollectionEditor

Discussion in 'ASP .Net Building Controls' started by Barry manilow, Aug 30, 2007.

  1. I'm dying here. I've scoured the internet and msdn documentation many times
    over, and I can't find anything to solve my problem. This is my last hope.
    I'm on hands and knees begging for help here ...

    I've got a custom control (Toolbar), that has an ArrayList collection
    property (called Buttons). The Buttons property holds objects that are to be
    displayed on the toolbar. The items that can be added to the toolbar are of
    varying types (imagebuttons, checkboxes, dropdowns, textboxes, separators,
    etc), which is why I'm using an ArrayList instead of a strongly typed
    collection. I've created a custom CollectionEditor to allow the managment of
    items on a toolbar in the designer. The collectionEditor works, in that it
    allows you to add items of varying types to the collection. The problem is,
    that when you then select one of those items, you can't edit it's properties
    in the property grid that's on the right hand side of the collection editor.
    instead, it just shows a generic Object, with one uneditable property, Value,
    who's value is the type of the item that is selected.

    From everything I've read (which is mostly based on the 1.1 framework, but
    I'm using 2.0), all you have to do to get a custom CollectionEditor working
    is to override the CreateNewItemTypes() method to return the types of objects
    that users can add to the collection, and it'll take care of the rest. I've
    done that, and that does allow me to add different types to the collection in
    the designer, but as I said, once I do, I then can't edit the properties of
    those items. I've also read that I need to put an ExpandableObjectConverter
    TypeConverter on the class declarations for the objects that are going to be
    added to the collection, and I've tried that, but had no luck Thinking that
    maybe I've got a problem with some of the custom controls I've created to go
    in the collection, I've tried setting it up so that the items that can be
    added to the collection are standard web controls (Label, Hyperlink, Textbox,
    etc), and I still get the same results. What am I missing?


    I've included the relevant sections of my code below:


    TOOLBAR CLASS

    1
    2
    3 <ToolboxData("<{0}:Toolbar runat=server></{0}:Toolbar>"),
    ParseChildren(True), PersistChildren(False)> _
    4 Public Class Toolbar
    5 Inherits WebControl
    6
    7 Private _Panel As Panel
    8 Private _Buttons As ArrayList
    9
    10 #Region " Public Properties "
    11
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    Editor(GetType(ToolbarCollectionEditor), GetType(UITypeEditor)),
    PersistenceMode(PersistenceMode.InnerProperty)> _
    12 Public ReadOnly Property Buttons() As ArrayList
    13 Get
    14 If _Buttons Is Nothing Then _Buttons = New ArrayList
    15 Return _Buttons
    16 End Get
    17 End Property
    18 #End Region
    19 End Class



    CUSTOM COLLECTION EDITOR

    1 Imports System.ComponentModel
    2 Imports System.ComponentModel.Design
    3 Imports System.Web.UI.WebControls
    4 Imports System.Reflection
    5
    6 Public Class ToolbarCollectionEditor
    7 Inherits CollectionEditor
    8
    9 Private SupportedTypes As System.Type()
    10
    11 Public Sub New(ByVal newType As Type)
    12 MyBase.new(newType)
    13 SupportedTypes = New System.Type() {GetType(ToolbarButton),
    GetType(ToolbarSeparator)}
    14 End Sub
    15
    16 Protected Overrides Function CreateNewItemTypes() As System.Type()
    17 Return SupportedTypes
    18 End Function
    19 End Class
     
    Barry manilow, Aug 30, 2007
    #1
    1. Advertising

  2. No one has any ideas on this?
     
    Barry manilow, Sep 4, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. michael
    Replies:
    0
    Views:
    449
    michael
    May 1, 2004
  2. gozza
    Replies:
    1
    Views:
    142
    gozza
    Feb 2, 2004
  3. gozza

    UrlEditor from a CollectionEditor again

    gozza, Feb 3, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    171
    gozza
    Feb 3, 2004
  4. michael
    Replies:
    0
    Views:
    116
    michael
    May 1, 2004
  5. Nathan Phelps

    CollectionEditor is always "Object Collection Editor"

    Nathan Phelps, May 4, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    197
    Nathan Phelps
    May 8, 2004
Loading...

Share This Page