Control Addition safety handling

  • Thread starter Thread starter joeycalisay
  • Start date Start date
J

joeycalisay

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!
 
joeycalisay said:
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.
 
Back
Top