Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subclassing .Net base classes
Message
De
28/08/2002 17:26:55
 
 
À
28/08/2002 17:08:29
Christian Cote
Les Logiciels Onoma Inc.
Longueuil, Québec, Canada
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00694357
Message ID:
00694683
Vues:
8
I have no idea if it's general practice in .NET or not, but I think it's a good idea anyway.

As far how to do it, you can do it in one class programmatically if you want to, just like we did in VFP. Here's an example to get you started.
namespace MyCustomClasses

public class MyComboBox : System.Windows.Forms.ComboBox
{
    // any properties you'd like to use

    public MyComboBox ()
    {
        // any constructor event you'd like to include
    }

    // any methods you'd like to define

    public virtual void DataBind(System.Data.DataTable Data, string Stuff)
    {
        this.DataBindings.Add("Selected Value", Data, Stuff);
    }
}

public class MyTextBox : System.Windows.Forms.TextBox
{
    // any properties you'd like to use

    public MyTextBox()
    {
        // any constructor event you'd like to include
    }

    // any methods you'd like to define

    public virtual void DataBind(System.Data.DataTable Data, string Stuff)
    {
        this.DataBindings.Add("Text", Data, Stuff);
    }
}

// and any other ones you'd like to do ...
Notice that I have a method called DataBind. We stick this in all our subclasses (although not necessary, it gives an easy way to bind the object to data).


HTH
~~Bonnie



>Is it a general practice in .Net? Also, do you know where could I find sample code (or article)? I bought several books but all I can find is how to subclass composite user control.
>
>Again, thank you 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