I'm writing a .Net component in C#. Let's name it component A. This
component
represents a collection of other .net components ( component B ) that are
not visible design
time in VS 2003. Component B provides several events. I take advantage of
the .net Collection
Editor and the addition and removal of those components (B) is done only
through component A's
property that returns the collection of B components.
What is the problem - I couldn't find ANY way to make the collection editor
show the events
for the items in the collection. By default it only shows their properties
and not the events.
And I really need access to those events in order to avail the user to
attach to them.
My solution:
I provided an external events tab for component A. This tab (derivative of
System.Windows.Forms.Design.EventsTab) overrides the GetProperties method
and iterates through
all items in A's collection, gathers their events, sets unique category
names and returns them.
The result is a beautiful customized tab, that lists the events of all items
(of type B) that it
contains.So far so good.
Unfortunately this approach turned out to have issues. When you double click
on an event in the
standard events tab the designer generates for you a method of the
appropriate delegate type
and binds it to your event in the InitializeComponents() method of the
windows form that
contains the component. Providing the custom event tab that lists all items
of type B in the
component A's collection solves half the problem - it lists all items'
events, but when you
double click them the designer generates the appropriate method but then it
seems that it looks
for the event in component A, which does not have such. So after failing to
find the event
no code is generated for attaching it.
I tried several solutions but none of them solved the problem.
I don't have much experience in programming .Net components and I would
really appreciate
any help on this issue.
Thanks in advance,
Alex