AddHandler needed in designer generated code

  • Thread starter Thread starter Marina
  • Start date Start date
M

Marina

Hi,

I have a component that implements ISupportInitialize, so the code in
InitializeComponent is something like:

theComponent.BeginInit()

' Set theComponent properties

theComponent.EndInit()

Now, EndInit, needs to raise an event, such that the end developer can
handle it, and perform some other code to be done to the component, before
EndInit actually finishes it's work.

Now, the problem is that VB, uses the Handles clause to define event
handlers in the designer. The problem of course, is that this Handles,
doesn't hook up the event until InitializeComponent finishes - at which
point EndInit has been called, and the event fired and it is too late.

Now, in C#, the event handler is hooked up programmatically, and the
designer generates explicit code for this in InitializeComponent - so it
would work there.

Given that this is VB, is there any way to get the designer to generate
AddHandler code?

Any other workaround suggested?
 
The point is I want it to be generated somehow by the designer. This is a
component that end developers will use - and they shouldn't be going in to
do this by hand.

Like I said, if this was C#, this would not be an issue. But how can this be
done in VB?
 
have you tried using custom serializers?

Marina said:
The point is I want it to be generated somehow by the designer. This is a
component that end developers will use - and they shouldn't be going in to
do this by hand.

Like I said, if this was C#, this would not be an issue. But how can this be
done in VB?

InitializeComponent
 
Back
Top