views:

1089

answers:

1

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...

The GenericEventArgs<T> class looks like this:

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?

+3  A: 

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

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.

John Saunders
Um... how do I use this? for an event? public event GenericHandler<string> Search; ?
Svish
That's what I'd try. Does it not work?
John Saunders
Seems like it did yes :D Thank you!
Svish
Actually... There seems to be something more going on here... the event shows up now, but when I double click it, i get the name searchTextBox_Search in the box, but it jump sto nowhere. If I double-click it again, I go to the method, but it looks like this: private void searchTextBox_Search(object sender). In other words, the event args part is missing =/ When I write searchTextBox.Search += and then press TAB, then I get a method with the correct signature... what is going on here...
Svish
And of course, it wont compile until I have fixed the signature of that method to what it should be... so the signature of the original delegate and event is correct.
Svish