我创建了一个自TDataSet派生的自定义组件。
现在,我从dsTable
名为的自定义类型创建了一个集合gttTables
。(所有代码都在下面)
当我将组件放到窗体上时,集合将gttTables
显示在中,property window
并且当我单击3dotted按钮时,Collection Editor Windows
将按预期出现。
在中,Collection Editor Windows
我可以单击Add
,这将在窗口中添加一个新项目,该项目似乎是dsTable
我所期望的类型。
现在解决问题。
在中,Collection Editor Windows
我无法看到/更改dsTable
左侧列表中每个属性的任何属性。右侧仅显示Value
值为gttControls.dsTable
。
让我告诉你这张照片的意思
我希望看到每个属性都dsTable
添加到Collection Editor Windows
此处,因此我可以对其进行编辑。
这是我完整的代码。
我的问题是我应该怎么做,以便我可以编辑添加dsTable
到其中的每个属性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; }
}
编辑
我看了看如何创建与属性网格一起使用的自定义集合编辑器表单?尽管它包含有用的信息,但对于我来说似乎没有必要。@Serg的答案解决了我的问题
您应该使您的dsTable
类属性public
能够使用以下命令编辑这些属性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.
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句