Events and Application.DoEvents()

J

Jay Dee

Can anyone explain to me how to trigger events in a control.

I have overridden the text class of a control and stored the text as
List<char>.
Because I am not calling the base.Text method from within the
overridden method the TextChainged event is not being raised.

If I add OnTextChanged(new EventArgs()) to the overridden method then
this will call the text changed event, but then I am having trouble
when the control is first initialised as the OnTextChanged() event is
not normally triggered when the control is being initialised.

I am wondering weather this has something to do with the SuspendLayout
(); and ResumeLayout(false); calls that the designer adds to a control
that is used at design time but I don’t think it is relevant.

Another thought is weather it has something to do with the Events
property of the control If I am not mistaken the OnTextChanged is not
normally called until a call to Application.DoEvents() in witch case
the overridden property could be still adding the OnTextChanged method
to a list that is being called at the end of the initialize.

To be honest I don’t really have a clue, could someone point me in the
right direction.

Thanks

Jay Dee
 
J

Jay Dee

Thanks Peter, you have been a grate help. I have fixed the problem
that turned out to be nothing to do with what I was on about anyway,
by unhooking the event causing the problem then hocking it back after
making the change.

The reason I have not called the base method was for performance
mainly as the text is very large and I wanted to be able to access the
underlying char array rather than having to pass the whole string
every time I was changing one char.

Thanks a lot

Jay Dee
 

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