首页 > 解决方案 > 如何在 WinForms 设计器中隐藏自定义属性中的某些对象?

问题描述

我有一个UserControl包含例如一个属性

public Button TargetButton { get; set; }

还包含UserControl例如 3 个按钮。

现在我有一个继承自此的主 UI 或控件UserControl

UI 控件有一个Button. 现在我认为 PropertyGrid 或 VS Desginer 中的 TargetButton 将只显示 UiControl 中的按钮。但实际上它显示了所有按钮。UI 控件的核心按钮UserControl和普通按钮。

如何从 PropertyGrid 或 VS Designer TargetButton 属性选择列表中排除 UserControl 的按钮?

例如: UserControl 中的属性如

[TypeConverter(ExcludeObjects(coreBtn1, coreBtn2 ))]

所以我只需要阻止我的属性在基本用户控件上选择核心按钮。但只有我可以在继承自 UserControl 的 Main Control 或 UIControl 中选择一个按钮

标签: c#.netwinformsuser-controlsdesigner

解决方案


推荐阅读