Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在设计器的“集合编辑器窗口”中创建可编辑对象?_C#_Visual Studio_Winforms_Visual Studio 2015_Custom Controls - Fatal编程技术网

C# 如何在设计器的“集合编辑器窗口”中创建可编辑对象?

C# 如何在设计器的“集合编辑器窗口”中创建可编辑对象?,c#,visual-studio,winforms,visual-studio-2015,custom-controls,C#,Visual Studio,Winforms,Visual Studio 2015,Custom Controls,我创建了一个自定义组件,它来自TDataSet。 现在,我从名为gttTables的自定义类型数据表创建了一个集合。所有代码如下 当我将组件拖放到表单上时,集合gttTables将显示在属性窗口中,当我单击3dotted按钮时,集合编辑器窗口将按预期显示。 在“集合编辑器”窗口中,我可以单击“添加”,这将在窗口中添加一个新项,该项的类型似乎与我预期的类型相同 现在来看问题。 在集合编辑器窗口中,我无法查看/更改左侧列表中每个数据表的任何属性。右侧仅显示值gttControls.dsTable。

我创建了一个自定义组件,它来自TDataSet。 现在,我从名为gttTables的自定义类型数据表创建了一个集合。所有代码如下

当我将组件拖放到表单上时,集合gttTables将显示在属性窗口中,当我单击3dotted按钮时,集合编辑器窗口将按预期显示。 在“集合编辑器”窗口中,我可以单击“添加”,这将在窗口中添加一个新项,该项的类型似乎与我预期的类型相同

现在来看问题。 在集合编辑器窗口中,我无法查看/更改左侧列表中每个数据表的任何属性。右侧仅显示值gttControls.dsTable。 让我告诉你我对这幅画的意思

我希望在此处看到添加到集合编辑器窗口的每个数据表的属性,以便编辑它们

这是我的完整代码。 我的问题是,我应该怎么做才能在集合编辑器窗口中编辑每个添加的数据表的属性

编辑 我看了看,虽然它包含有用的信息,但在我的情况下似乎没有必要。@Serg的答案解决了我的问题

您应该公开您的数据表类属性,以便能够使用PropertyGrid编辑这些属性

您应该公开您的数据表类属性,以便能够使用PropertyGrid编辑这些属性


看看,这是否回答了你的问题@OlivierRogier谢谢你的链接,我现在会研究它看看,这是否回答了你的问题@奥利维耶罗吉尔:谢谢你的链接,我现在就来研究它。我这么简单,怎么可能看不到这个。谢谢你这么简单,我怎么能看不到这一点。多谢各位
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;  }
}
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.
}