I was curious about the following scenario but couldn't find the exact
handling using disassembler:

What happens if an instance of a control already added in the Controls
collection of a form is added again? Is there a reference check on each
control addition to handle the said scenario?

It is possible that there is a reference checking since the OnControlAdded
event is not raised for the second time. Anyone who can shed some light on
the said handling? Thanks a lot!

Re: Control Addition safety handling by Herfried

Herfried
Mon Jan 03 05:30:10 CST 2005

"joeycalisay" <hcalisay@_spamkiller_codex-systems.com> schrieb:
> What happens if an instance of a control already added in the Controls
> collection of a form is added again? Is there a reference check on each
> control addition to handle the said scenario?
>
> It is possible that there is a reference checking since the OnControlAdded
> event is not raised for the second time. Anyone who can shed some light
> on
> the said handling? Thanks a lot!

Yes, the 'Controls' collection checks if the control has already been added
and then adds the control only if it's not already in the collection.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>