Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CellTemplate.EditType
Message
De
31/08/2007 05:54:55
 
 
À
28/08/2007 10:36:25
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
01250907
Message ID:
01251593
Vues:
12
Worked this out - basically just needed to set the type using a public property and override the Clone() method. In case anyone is interested:
class LLUserControlCell : DataGridViewTextBoxCell
    {
        Type thisType;
        public void EditingType(Type t)
        {
            set {thisType = value;}
            get { return thisType;}

        public override Type EditType
        {
            get { return thisType; }
        }

        public override Object Clone()
        {
            LLUserControlCell c = (LLUserControlCell) base:Clone();
            c.EditingType = this.EditingType;
        }
    }
    //Then:
LLUserControlCell ucc = new LLUserControlCell();
ucc.EditingType = Type.GetType("myClass");
DataGridViewColumn dgvc = new DataGridViewColumn(ucc);
>I've subclassed a DataGridViewCell thus:
class LLUserControlCell : DataGridViewTextBoxCell
>    {
>        Type thisType;
>        public void SetEditType(Type t)
>        {
>            thisType = t;
>        }
>
>        public override Type EditType
>        {
>            get { return thisType; }
>        }
>    }
>
Then I use:
>LLUserControlCell ucc = new LLUserControlCell();
>ucc.SetEditType(Type.GetType("myClass"));
>DataGridViewColumn dgvc = new DataGridViewColumn();
>dgvc.CellTemplate = ucc;
When I add this column to a DataGridView at runtime all looks well (the Datacolumns CellTemplate.EditType returns the expected type) but the actual cells in the column return null for the EditType. Other specific property settings of the CellTemplate (e.g. ToolTipText) are preserved. Can this be done (and, if not, is there any way to avoid having to create subclassed DataGridViewCells for each required UserControl type) ?
>Regards,
>Viv
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform