【发布时间】:2021-04-11 06:26:43
【问题描述】:
我创建了一个从 TDataSet 派生的自定义组件。
现在我从名为gttTables 的自定义类型dsTable 创建了一个集合。 (所有代码都在下面)
当我将组件放在表单上时,集合 gttTables 会显示在 property window 中,当我单击 3dotted 按钮时,Collection Editor Windows 会按预期显示。
在Collection Editor Windows 中,我可以单击Add,这将在窗口中添加一个新项目,该项目似乎是我预期的dsTable 类型。
现在解决问题。
在Collection Editor Windows 中,我无法查看/更改左侧列表中每个dsTable 的任何属性。右侧只显示Value,值为gttControls.dsTable。
让我告诉你我对这张照片的意思
我想在这里查看添加到Collection Editor Windows 中的每个dsTable 的属性,以便我可以编辑它们。
这是我的完整代码。
我的问题是我应该怎么做才能编辑Collection Editor Windows 中每个添加的dsTable 的属性?
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; }
}
编辑
我查看了How do you create a custom collection editor form for use with the property grid?,虽然它包含有用的信息,但在我的情况下似乎没有必要。 @Serg 的回答解决了我的问题
【问题讨论】:
-
@OlivierRogier 谢谢你的链接,我现在研究一下
标签: c# visual-studio winforms visual-studio-2015 custom-controls