我目前正在从事一个托管 WinForms 设计器的项目。我正在使用 PropertyGrid
来显示放置在 DesignSurface
上的控件的操作属性。
我已经创建了 UITypeEditor
来修改我的自定义控件属性的值。
如何在 PropertyGrid
中按下 Delete 键时将属性值重置为 null
。
最佳答案
实际上,您所要做的就是将“DefaultValue”属性添加到您的属性中,并指定默认值为空。
例子:
[DefaultValue(typeof(Image), null)]
public Image MyLittlePicture { get; set; }
关于c# - 在 PropertyGrid 中按下 Delete 键时设置属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3830515/