Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to override a click method in a button on a form?
Message
De
18/06/2004 01:22:46
 
 
À
17/06/2004 21:39:20
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00913730
Message ID:
00914910
Vues:
8
Mark,

>>So, I can't do this in .Net? And therefore, would I have to go into the base class and put a breakpoint there?

Right. The reason that you have to put the breakpoint in the base class in the case of eventhandlers is because the eventhandler in the base class executes before the eventhandler you've created on your form. And you can't do a base.ClickHandler() because you can't override a button's Click eventhandler in the form, you can only override it in the sub-class of the button.

>>A more practical question/example would maybe be this... If I create a button class that does some special stuff, and I create a "Hook" method in the class for the developer to put some custom code when he uses my button on his form. Is it true then that in order for the developer to be able to enter his hook method code, he would have to first, sub-class the button (saving it in a .cs file), enter his hook code there, and then drag his sub-classed button on the form? Gee, if that's true, then I'm really starting to miss VFP already! :)

Yes, the developer would only be able to write his own "Hook" code in a sub-class of your button. But, there's no reason to have one .cs file for every sub-classed control!!! That would be crazy. You can easily put all your sub-classed controls into one .cs file and they can be easily dragged to the form from the ToolBox.

~~Bonnie



>Thank you for your very helpful response Bonnie! Actually, what let me to this, is that I'm working in MM.Net and I wanted to debug/step through the code that happens in one of the MM buttons (mmButtonClose for instance) I dropped on a form. In VFP this was so simple. I'd just put my breakpoint on a DODEFAULT command in the click() of the button that I dropped on the form. Then I can step through the base class code.
>
>So, I can't do this in .Net? And therefore, would I have to go into the base class and put a breakpoint there? Seems weird to a VFP'er. I know VFP does things a little differently as far as oops and form containers.
>
>A more practical question/example would maybe be this... If I create a button class that does some special stuff, and I create a "Hook" method in the class for the developer to put some custom code when he uses my button on his form. Is it true then that in order for the developer to be able to enter his hook method code, he would have to first, sub-class the button (saving it in a .cs file), enter his hook code there, and then drag his sub-classed button on the form? Gee, if that's true, then I'm really starting to miss VFP already! :)
>
>Thanks again for your help!
>
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