C
Charlie Williams
One of the main reasons for using inheritance is so you
don't have to reinvent the wheel with every app you
write. UserControls exist for you to inherit from so you
don't have to write all the plumbing code yourself, such
as notifying child controls when they should be
repainted.
Are there events fired in your custom collection when
controls are added and deleted? If so, you can use these
to update the Controls collection of the user control
whenever anything changes.
CollectionProperty.ControlAdded += new EventHandler
(ControlAdded);
void ControlAdded(object sender, EventArgs e){
this.Controls.Add(sender);
}
You don't need to use events, of course, but it would
make it easier to keep track of changes. Otherwise, just
remember to make changes to both collections whenever you
change one.
Charlie
don't have to reinvent the wheel with every app you
write. UserControls exist for you to inherit from so you
don't have to write all the plumbing code yourself, such
as notifying child controls when they should be
repainted.
Are there events fired in your custom collection when
controls are added and deleted? If so, you can use these
to update the Controls collection of the user control
whenever anything changes.
CollectionProperty.ControlAdded += new EventHandler
(ControlAdded);
void ControlAdded(object sender, EventArgs e){
this.Controls.Add(sender);
}
You don't need to use events, of course, but it would
make it easier to keep track of changes. Otherwise, just
remember to make changes to both collections whenever you
change one.
Charlie