a UserConctrol needs to raise an event when it starts

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
 
N

Noozer

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
 
J

Just Me

sound good, I'll try it now

Thanks a lot

Noozer said:
Use the PAINT event to raise the event. Set a flag when fired so you don't
fire it on every Paint event
 
C

Cor Ligthert

Just me,

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

Cor
 
J

Just Me

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top