Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Override custom method in subclass
Message
De
08/09/2009 10:53:01
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Divers
Thread ID:
01423040
Message ID:
01423069
Vues:
54
Naomi,

>>You can do this in .NET - see Gregory's reply
>
>I saw it, but may be we understood the problem differently. As I understood, you can not put custom logic in the form's instance of the class as you can do in FoxPro - see the mentioned discussion.
>
>You can put all the logic into the subclass.

Are you referring to this?

in my DataGrid class. But now, how can I implement the actual logic for the instances of this class in my form?

You can't. A virtual method (or abstract) is to be overriden in a subclass not an instance. If the class you are creating is a concrete class you need to implement your logic in that class. Your method may need to be abstract (sorry for the confusion with that word) enough to acommodate your needs in the instance usage of it on your form. If your method is FormatGrid then you will have to pass in enough parameters to do what you need for that instance or you will need to set properties that will achieve it.
Tim


These are not the same questions and the answers are not the same for both. Just to be clear about what I responded to in your referenced question. Your question was how to implement custom grid logic in the instance of it placed on a form. The answer I gave you was correct, because you need to implement your logic in a class not an instance. The key is in the difference between a class and an instance.

The question above has to do with overriding a method and still calling the base code that goes with it. There are at least a couple of ways to do this; one of which was shown by Gregory. One method you can't just completely override is the constructor but it is easy to get around that. Put your code in a different method of the base class and then call that method from the constructor. Then you can override that different method in your subclass. oh, I digressed; sorry. Bottom line if you can't override methods then we would really be up a creek for oop.
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform