StrataFrame Forum

How to create a method on base class that known members from subclass?

http://forum.strataframe.net/Topic12418.aspx

By Fabian R Silva, - - 11/5/2007

I Created a BaseForm Class (inherited from Strataframe form) and create a sublass of it (countriesForm)



How I can create a method on BaseForm that known members of the inherited form?



Suppose I create a method named "ChangeTextBoxBackColor" and I want to call it under some circunstanse on my countriesform to change all the textbox dropped on it.



When I debug the method "ChangeTextBoxBackColor" on the base, I not see the textboxes from the countriesForm.



thanks!
By Trent L. Taylor - 11/5/2007

You have to recursively call the Controls collection to dig down and get them.  The Controls collection on a form (or any control object) is not flat and so you have to recursively enumerate the Controls collections to get to all of the objects.  More than likely you put your textboxes in a group box, so the Form.Controls will only see the group box and not the text box.  The text boxes will be in the GroupBox.Controls collection.

Private Sub SearchControls(Byval controlItems As Control.ControlCollection)
    For each item as Control in controlItems
        '-- Cycle through the child objects
        If item.Count > 0 Then
            SearchControls(item.Controls)
        End If
    Next
End SUb
By Fabian R Silva, - - 11/5/2007

I suppose and do it,

the only way is that I pass parameters, not another way that base see sublass / implementation



Thanks for all replies and supress all my doubts.


By StrataFrame Team - 11/6/2007

Yeah, any time the base class needs to see something from the subclass, you need to either pass the data through parameters or have a property/method that is overriden (even defined as MustOverride) that the base class can call to pull from the subclass.