Prevent controls being added to UserControl

B

BluDog

Hi

I have a basic UserControl that i want to be able to prevent controls
being added to, i was thinking about catching the ControlAdded event
and then removing the control immediatley after, but was wondering if
there was a better approach.

Cheers

Blu
 
C

Cor Ligthert

Bludog,

I took some time to make a sample that would fit your previous problem,
however not any reaction on that.

Cor
 
H

Herfried K. Wagner [MVP]

* BluDog said:
I have a basic UserControl that i want to be able to prevent controls
being added to, i was thinking about catching the ControlAdded event
and then removing the control immediatley after, but was wondering if
there was a better approach.

Just FMI: Why?
 
B

BluDog

Just FMI: Why?

Im a writing a control from scratch that behaves a little like a
treeview, and accepts only controls of a certain type via a collection
property. I want controls only to be added and removed through the
collection. To be honest it makes no odds as the code is only for my
use, but i get these niggly little 'wonder ifs' that i have to
explore!
 
B

BluDog

Bludog,

I took some time to make a sample that would fit your previous problem,
however not any reaction on that.

Cor

Sorry Cor, your example came after i had resolved it with the help of
another poster. I only later say your post that suggests a similar
solution. Sorry to offend, you help and examples have always proven
extremely valuable.
 

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