R
Ron Vecchi
I have a custyom control that has a property which wraps a collection. When
I add controls to the collection the OnPaint method of these newly added
controls never get fired.
But if I take the controls in the collection and add them to the custom
controls ControlCollection the OnPaint method is called.
I would like to use my Collection property but It seems that the controls
need to be added to the ControlCollection for them to work.
In my custom controls on paint method I loop through the Collection and add
them to the ControlCollection so the OnPaint will be called.
I'm pretty new to this, just wondering if this is an ass backwards way to
do this. Seems like it is and that I am missing something.
--------------------------------------
// myothercontrol OnPaint is never called from below example
MyCustomControl.CollectionPreoperty.Add(myothercontrol);
------------------------------------------------
////
// MyCustomControl OnPaint Method
// OnPaint menthod will get fired by using below example.
//
protected void OnPaint(PaintEventArgs pe){
foreach(MyCustomControl in this.CollectionProperty){
this.Controls.Add(MyCustomControl);
}
}
--------------------------------
I was thinking that in the set and get accessor for the Collection Property
I could just get and set directly to the ControlCollection
but it still seems like I am wrong in my organization and thinking on this.
Any Insights?
I add controls to the collection the OnPaint method of these newly added
controls never get fired.
But if I take the controls in the collection and add them to the custom
controls ControlCollection the OnPaint method is called.
I would like to use my Collection property but It seems that the controls
need to be added to the ControlCollection for them to work.
In my custom controls on paint method I loop through the Collection and add
them to the ControlCollection so the OnPaint will be called.
I'm pretty new to this, just wondering if this is an ass backwards way to
do this. Seems like it is and that I am missing something.
--------------------------------------
// myothercontrol OnPaint is never called from below example
MyCustomControl.CollectionPreoperty.Add(myothercontrol);
------------------------------------------------
////
// MyCustomControl OnPaint Method
// OnPaint menthod will get fired by using below example.
//
protected void OnPaint(PaintEventArgs pe){
foreach(MyCustomControl in this.CollectionProperty){
this.Controls.Add(MyCustomControl);
}
}
--------------------------------
I was thinking that in the set and get accessor for the Collection Property
I could just get and set directly to the ControlCollection
but it still seems like I am wrong in my organization and thinking on this.
Any Insights?