【发布时间】:2011-06-16 07:47:19
【问题描述】:
我正在尝试使用 propertygrid 制作一个可配置/可编辑的对象。 这一切都很顺利,除了对象内的对象。
我有一个名为“ContactInformation”的对象/类。在该对象内部,我有一个名为“Correspondence”的对象。
这就是该部分的外观:
[Browsable(false)]
public Correspondence Correspondence
{
get;
set;
}
public int CorrespondenceStatus
{
get { return this.Correspondence.Status; }
set { this.Correspondence.Status = CorrespondenceStatus; }
}
public string CorrespondenceComment
{
get { return this.Correspondence.Comment; }
set { this.Correspondence.Comment = CorrespondenceComment; }
}
public DateTime CorrespondenceDate
{
get { return this.Correspondence.LastSend; }
set { this.Correspondence.LastSend = CorrespondenceDate; }
}
这样我可以在属性网格中显示对象内部的对象的属性/变量。
无论如何,当我现在编辑这些值并按 Enter 键或单击其他位置时,它不会保留我刚刚输入的值,而是变回原样..
有人知道为什么会这样吗?或者在 propertygrid 中的对象中显示对象的属性可能是一个更好的主意?
【问题讨论】:
-
也许简单刷新一下 propertyGrid 就可以解决它。更改数据后的“propertyGrid.refresh()”。
-
不,那没用..
-
@MichielMagendans,您在扩展器中成功编辑变量了吗?
标签: c# winforms class object propertygrid