Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inheritance in vb.net
Message
De
17/10/2010 10:41:35
 
 
À
17/10/2010 10:09:35
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
VB 8.0
OS:
Vista
Network:
Windows XP
Database:
Jet/Access Engine
Application:
Desktop
Divers
Thread ID:
01485789
Message ID:
01485806
Vues:
43
Sorry Gregory ... I didn't see your reply when I replied to Marc (my reply is almost word-for-word the same as yours!!)

~~Bonnie



>Sure, it can
>
>A class can only inherit from one class, but it can implement many interfaces
>An interface is only a contact to implement some methods and properties
>
>I think the vb syntax would be
>
>Public Class txtBase
>    Inherits textbox
>   Implements IIOEnable 
>
>End Class
>
>
>Have a look here http://msdn.microsoft.com/en-us/library/ms973803.aspx under 'Interface Inheritance'
>
>
>
>
>>Sounds promising. Btu if my "txtBase" can "implement" the interface, they can't "inherit" from textbox, can they?
>>
>>
>>>I would define an interface IIOEnable and have your subclassed controls implement that interface
>>>
>>>then - excuse the syntax - vb and c# mixture
>>>
>>>foreach ( Control ctrl in Me.Controls )
>>>{
>>>    IIOEnable ctrl1 = ctrl as IIOEnable ;
>>>    if( ctrl1 != null )
>>>         ctrl1.ioEnable(value);
>>>
>>>}
>>>
>>>
>>>
>>>
>>>
>>>>I have subclassed textboxes, panels and buttons. For each of those controls, I wrote an IOEnable method. I would like my (subclassed) form to execute these methods. I came up with something like this, which works, but am wondering if there is not a more generic approach to this, because now, each time I subclass a control I have to kind of "register" it here and in every container.
>>>>
>>>>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
>>>>     If TypeOf ctrl Is btnBase Then
>>>>         Dim ctrl1 As btnBase = ctrl
>>>>         ctrl1.ioEnable(value)
>>>>     End If
>>>> Next
>>>>
>>>>
>>>>In VFP this looked like this
>>>>
>>>>for each o in this.Controls
>>>>        if !pemstatus(o,'IOEnable',5)
>>>>            loop
>>>>        endif
>>>>        o.IOEnable()
>>>>    endif
>>>>endfor
>>>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform