Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Overriding properties in subclasses
Message
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Titre:
Overriding properties in subclasses
Divers
Thread ID:
01137567
Message ID:
01137567
Vues:
62
Seems like this should be an easy one. I have the code below (sample code from Bonnie Berent) to create a one-off class. Now, if I want to change the default setting for the DropDownStyle, how do I do that?
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace MyCompany.WinUI.MyClasses
{
    public class MyComboBox : System.Windows.Forms.ComboBox
    {
        // Override inherited settings with new default values.
        public new ComboBoxStyle DropDownStyle = ComboBoxStyle.DropDownList;
    }
}
Without the new keyword, the compiler tells me I'm hiding an inherited member and if that is the intended behavior, I should use new. So, while this compiles fine, when I try to use this control on a WinForm in another project, that property still defaults to DropDown (not DropDownLlist). I'm sure it has to be something simple I'm missing. By the way, I built this in a class project instead of a component project, does that make a difference?

TIA,
Chad
_________________________________
There are 2 types of people in the world:
    Those who need closure
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform