添加 datagridviewcolumn 属性设计时
我有这个问题,我创建了自己的 datagridviewcolumn,我希望添加一些可以在设计时编辑中更改的属性... 这是我的代码:
private int nMaxLength;
[Description("Fondoscala valore"), Category("Sea")]
public int MaxLength
{
get { return nMaxLength; }
set { nMaxLength = value; }
}
事实上没问题,当您打开列编辑器时,您会在 Sea 类别下看到此属性,您可以更改它,但是当您更改它时,如果您转到 .Designer.cs 文件,您会看到MaxLength 值为 0.. 没有变化... 有什么问题吗? 提前致谢
I have this problem, I created my own datagridviewcolumn and I wish add some properties that you can change in designtime editing...
here is my code:
private int nMaxLength;
[Description("Fondoscala valore"), Category("Sea")]
public int MaxLength
{
get { return nMaxLength; }
set { nMaxLength = value; }
}
and in fact is ok, when you open the column editor, you see this property under the Sea category and you can change, but when you changed it, if you go to the .Designer.cs file, you see the MaxLength value to 0.. no change...
what's the problem??
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
表单设计器做了一些内部欺骗,以便允许您在设计时更改列类型(例如,从
DataGridViewTextBoxColumn
到DataGridViewButtonColumn
)。因此,设计器依赖于具有正确实现的Clone()
方法的DataGridViewColumn
子类,即:如果您不重写
Clone ()
方法中,设计器不会提交您对自定义属性值所做的任何更改。The Forms Designer does some internal trickery in order to allow you to change the column type (e.g. from
DataGridViewTextBoxColumn
toDataGridViewButtonColumn
) at design time. As a result of this, the designer relies on your subclass ofDataGridViewColumn
having a correctly-implementedClone()
method, i.e:If you do not override the
Clone()
method, the designer will not commit any changes you make to custom property values.