事件未显示在Property Grid中

时间:2021-03-23 15:52:00

I am creating a special search text box. Among other things it have these two events:

我正在创建一个特殊的搜索文本框。除此之外还有这两个事件:

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

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

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

Thing is that only the bottom two shows up in the design view property event explorer thingy (whatever it's name is...). And I am wondering why. Is it because I am not using the standard EventArgs? That shouldn't be the case though, cause I mean, there are other events not using that... like the key press related events, etc...

事情是只有底部的两个显示在设计视图属性事件资源管理器thingy(无论它的名称是什么......)。我想知道为什么。是因为我没有使用标准的EventArgs吗?那不应该是这种情况,因为我的意思是,还有其他事件没有使用...就像关键的新闻相关事件等...

The GenericEventArgs<T> class looks like this:

GenericEventArgs 类如下所示:

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

What am I doing wrong here?

我在这做错了什么?

1 个解决方案

#1


I suspect that the Property Grid does not support your double-generic EventHandler class. Try this:

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

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

If that doesn't work, try a completely non-generic handler, if only to see if that's where the problem is.

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

If this is the problem, then I suggest you create a bug report about it on Connect, then post the URL to the bug here so we can vote on it.

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

#1


I suspect that the Property Grid does not support your double-generic EventHandler class. Try this:

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

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

If that doesn't work, try a completely non-generic handler, if only to see if that's where the problem is.

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

If this is the problem, then I suggest you create a bug report about it on Connect, then post the URL to the bug here so we can vote on it.

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