0

Is there a more elegant way to do this? :

For Each ctrl As Control In Me.Controls
                If TypeOf ctrl Is txtBase Then
                    Dim ctrl1 As txtBase = ctrl
                    ctrl1.ioEnable(value)
                End If
                If TypeOf ctrl Is pnlBase Then
                    Dim ctrl1 As pnlBase = ctrl
                    ctrl1.ioEnable(value)
                End If
           Next

"Me" is a form. and txtBase and pnlBase are subclassed from textbox and panel respectively. Both the classes have .ioEnable method.

Ideally I would like to add an abstact (overridable) .ioEnable method to the Control class, so that I could code :

For Each ctrl As Control In Me.Controls
                       ctrl.ioEnable(value)
                   Next

If I then write a .ioEnable for my btnBase and my pgfBase, I would not have to worry about this anymore.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by lolafuertes
0

The best way is to create user contros that ineherits from the control base.

On the user controls you can add as many properties, functions and methods you need.

In this example you should create two user controls: one for text base and the other for the panel.

When defining the user control youput inside the original control to be expanded.
Then on the UserControl class, you can add properties and methods to manage the original control.

Hope this helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.