1

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

GuidoG
  • 11,359
  • 6
  • 44
  • 79
  • Take a look at [How to Edit and Persist Collections with CollectionEditor (CodeProject)](https://www.codeproject.com/Articles/5372/How-to-Edit-and-Persist-Collections-with-Collectio) and [Creating a Custom Collection for Use in a PropertyGrid (CodeProject](https://www.codeproject.com/Articles/24332/Creating-a-Custom-Collection-for-Use-in-a-Property) and [Design-Time Support for Custom Controls](https://flylib.com/books/en/2.742.1/design_time_support_for_custom_controls.html) –  Jan 05 '21 at 13:40
  • Does this answer your question? [How do you create a custom collection editor form for use with the property grid?](https://stackoverflow.com/questions/7530074/how-do-you-create-a-custom-collection-editor-form-for-use-with-the-property-grid) –  Jan 05 '21 at 13:41
  • @OlivierRogier Thanks for the link, I will study it now – GuidoG Jan 05 '21 at 13:45

1 Answers1

4

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.
}
Serg
  • 3,454
  • 2
  • 13
  • 17