带有 GenericItems 的 PropertyGrid GenericList
有没有一种方法可以显示和编辑从抽象泛型类派生的对象的 PropertyGrid (及其 CollectionEditor)中的值? 我没有只显示类似这样的属性:“IFilter´1”或“BaseFilter'1”其中 IFilter 是一个接口,而 BaseFilter 是一个抽象类。
此列表包含的所有对象:
List<IFilter<bool>> _activeFilter = new List<IFilter<bool>>();
有一个抽象类,实现 IFilter:
public abstract class FilterBase<T> : IFilter<T> { ... }
以及 FilterBase 的一些专门实现
public class SimpleBool : FilterBase<bool> {
public bool BoolValue { get; set; }
protected override bool Process(bool input) {
return input && BoolValue;
}
}
当我将这样一个“SimpleBool”类添加到上面定义的列表中时,PropertyGrid 将不会显示任何属性。但当我定义具有非泛型类型的泛型列表时,它显示一切正确。
有解决方案来完成这项工作吗?我尝试添加一些 TypeConverter 和自己的 CollectionEditor。显然没有运气=(
Is there a way to display and edit values in the PropertyGrid (and his CollectionEditor) of an object, which is derived from an abstract generic class?
I don't get the properties displayed only something like this: "IFilter´1" or "BaseFilter'1" Where IFilter is an Interface, and BaseFilter an abstract class.
All objects contained by this list:
List<IFilter<bool>> _activeFilter = new List<IFilter<bool>>();
There is one abstract class, implementing the IFilter:
public abstract class FilterBase<T> : IFilter<T> { ... }
And a few specialized implementations of the FilterBase
public class SimpleBool : FilterBase<bool> {
public bool BoolValue { get; set; }
protected override bool Process(bool input) {
return input && BoolValue;
}
}
When I add such a "SimpleBool" class to the above defined list, the PropertyGrid wont display any of the Properties. But it displays all correct when I define an Generic List with a non generic Type.
Is there an Solution to get this work? I tryed to add some TypeConverter and an own CollectionEditor. Obviously without luck =(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经解决了。但这很奇怪..只需向抽象类“FilterBase”添加一些Property,仅此而已。
I have solved it. But its strange.. Just add some Property to the abstract class "FilterBase", thats all.