a UserConctrol needs to raise an event when it starts

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

Often I have a problem like the following:
..

This is the way I think things happen is:
If the usercontrol raises the event when it is first created (I.e., in it's
New, or in it's Enter event, or in it's HandleCreated event...) the Form,
which caused the control's New to run, is itself being created and is not
yet ready to receive an event, so the raised event is lost.

I could put a timer on the control or have the form somehow (via a call to a
sub or property...) cause the event to be raised, but that seems clunky.

Any suggestions?


Thanks
 
Just Me said:
Often I have a problem like the following:
.

This is the way I think things happen is:
If the usercontrol raises the event when it is first created (I.e., in it's
New, or in it's Enter event, or in it's HandleCreated event...) the Form,
which caused the control's New to run, is itself being created and is not
yet ready to receive an event, so the raised event is lost.

I could put a timer on the control or have the form somehow (via a call to a
sub or property...) cause the event to be raised, but that seems clunky.

Any suggestions?

Use the PAINT event to raise the event. Set a flag when fired so you don't
fire it on every Paint event
 
Just me,

Why are you not just calling in the new sub the event you want to call?

Cor
 
Cor Ligthert said:
Just me,

Why are you not just calling in the new sub the event you want to call?

Cor
I think you mean:
Why are you not just Raising in the new sub the event you want to raise

If so, as I said in the post - I think the control's New runs before the
form is ready to receive events.

But the first time the control's Paint is raised seems to be late enough so
that it works there (Info from to Noozer).

Thanks
 
Back
Top