GuidoG
GuidoG

Reputation: 12014

How to make editable objects in the designers `Collection Editor Windows`?

I created a custom component, derived from TDataSet.
Now I created a collection from a custom type dsTable named gttTables. (all the code is below)

When I drop the component on a form, the collection gttTables shows up in the property window and when I click on the 3dotted button, the Collection Editor Windows appears as expected.
In the Collection Editor Windows I can click on Add and that will add a new item in the window which seems to be of the type dsTable as I expected.

Now for the problem.
In the Collection Editor Windows I cannot see/change any of the properties of each dsTable in the list on the left. The right side only shows Value the value is gttControls.dsTable.
Let me show you what I mean with this picture

enter image description here

I would like to see the properties of each dsTable added to the Collection Editor Windows here instead, so I can edit them.

Here is my complete code.
My question is what should I do so I can edit the properties of each added dsTable in the Collection Editor Windows ?

public partial class gttDataSet : DataSet
{
    Collection<dsTable> _dsTables = new Collection<dsTable>();

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [Editor("System.ComponentModel.Design.CollectionEditor, System.Design", typeof(UITypeEditor))]
    [Category("GTT")]
    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    public Collection<dsTable> gttTables
    {
        get { return _dsTables; }
        set { _dsTables = value; }
    }
}

public class dsTable
{
    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
    string SelectText { get; set; }

    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
    string SelectTextForUpdate { get; set; }

    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
    string DesignWhereText { get; set; }

    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
    string UserWhereText { get; set; }

    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    bool IsStoredProcedure { get; set; }

    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    bool RetrieveColumns { get;  }
}

EDIT
I looked at How do you create a custom collection editor form for use with the property grid? and though it contains usefull information it seemed not necessary in my case. The answer of @Serg fixed my problem

Upvotes: 1

Views: 625

Answers (1)

Serg
Serg

Reputation: 4666

You should make your dsTable class properties public to be able to edit these properties with PropertyGrid

public class dsTable
{
    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
    public string SelectText { get; set; } // <--- changed here

    //make the same changes for other properties you want to edit.
}

Upvotes: 4

Related Questions