事件未显示在Property Grid中

Svi*_*ish 3 c# propertygrid events 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;
Run Code Online (Sandbox Code Playgroud)

事情是只有底部的两个显示在设计视图属性事件资源管理器thingy(无论它的名称是什么......).我想知道为什么.是因为我没有使用标准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; }
}
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

Joh*_*ers 5

我怀疑Property Grid不支持你的双通用EventHandler类.试试这个:

public delegate void GenericHandler<T>(object sender, GenericEventArgs<T> e);
Run Code Online (Sandbox Code Playgroud)

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

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