Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating my class based on existing control
Message
 
À
31/08/2002 15:04:37
Christian Cote
Les Logiciels Onoma Inc.
Longueuil, Québec, Canada
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Divers
Thread ID:
00695712
Message ID:
00695724
Vues:
9
Hi Christian,

To subclass a textbox, the approach is typically:

1. Create a new project using the Class Library type. In your case, call the project MyCtrls.
2. Then add a Reference to the System.Windows.Forms dll in the Reference section of the new project.
3. Rename Class1.vb to MyCtrls.vb
4. In the class code page that will show up on your desktop, replace what is there with the following:
Imports System.Windows.Forms

Public Class MyTxtbox
    Inherits TextBox

End Class
5. Build the project.
6. Go into your app project and add a reference to the MyCtrls.dll file.
7. To use the new subclass just type the following:
Dim oMyTextbox As New MyCtrls.MyTxtbox()
You want to add the subclasses into a separate project so you can add them to the Toolbox to drag and drop onto a form.

>HI,
>I tried to subclass a textbox control and I get an error telling me that I need to declare something
>Here is the code
>Imports System.Windows.Forms
>Namespace MyCtrls
>
> Public Class MyTxtbox
> Inherits System.Windows.Forms.TextBox
>
> End Class
>
>End Namespace
>
>As soon as I want to refer to MyTxtbox, vb.net is telling me "Declarartion expected". Also, intellisense in not functionning at that point (MyTxtbox. member list). What do I need to declare?
>
>Thank you for your help,
>Christian
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform