c# - 事件未显示在属性网格中

标签 c# events propertygrid windows-forms-designer

我正在创建一个特殊的搜索文本框。除其他事项外,它还有以下两个事件:

    [Category("Behavior")]
    public event EventHandler<GenericEventArgs<string>> Search;

    [Category("Property Changed")]
    public event EventHandler<EventArgs> ActiveColorChanged;

    [Category("Property Changed")]
    public event EventHandler<EventArgs> InactiveColorChanged;

事情是只有底部的两个显示在设计 View 属性事件资源管理器中(不管它的名字是什么......)。我想知道为什么。是不是因为我没有使用标准 EventArgs ?但这不应该是这种情况,因为我的意思是,还有其他事件没有使用它……比如按键相关事件等……

GenericEventArgs<T>类看起来像这样:

public class GenericEventArgs<T> : EventArgs
{
    public T Value { get; private set; }
    public GenericEventArgs() : this(default(T)) { }
    public GenericEventArgs(T value) { Value = value; }
}

我在这里做错了什么?

最佳答案

我怀疑Property Grid 不支持您的双泛型 EventHandler 类。试试这个:

public delegate void GenericHandler<T>(object sender, GenericEventArgs<T> e);

如果这不起作用,请尝试一个完全非通用的处理程序,如果只是为了查看是否是问题所在。

如果这问题,那么我建议您在Connect 上创建一个关于它的错误报告| ,然后在此处发布错误的 URL,以便我们对其进行投票。

关于c# - 事件未显示在属性网格中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/772036/

相关文章:

java - 任务计划和 DST 更改

c# - 如何从另一个窗体在窗体图片框上绘制矩形

c# - 如何注销匿名处理程序?

c# - ICustomTypeDescriptor、TypeDescriptionProvider、TypeConverter 和 UITypeEditor

c# - 检索集合和枚举选定值 WPF 属性网格

c# - 构造函数链接与基本构造函数调用相结合

c# - BrokerProperties REST header 值未显示在 .NET 客户端代码中

c# - 修改 PropertyGrid 和 TypeConverterAttribute 的默认行为

c# - 如何更新 Windows 窗体中的 StatusStrip

c# - 将 XML 数据(键/值对)加载到数据结构中