Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Class design
Message
De
27/05/2009 15:58:58
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01401807
Message ID:
01402332
Vues:
46
This message has been marked as a message which has helped to the initial question of the thread.
>>>>I'm not really clear on what you're asking - but see inline:
>>>>
>>>>>I want to subclass a DataGrid control (in .NET CE) environment. In particular, I want to have a common property _rowNumber and a common MouseUp event updating this number.
>>>>>
>>>>>This part I was able to figure out myself.
>>>>>
>>>>>Now, in addition I also want to have TableStyle as a property (can I use SET/GET the same way as with a regular property?)
>>>>Yes
>>>>>and a new signature for a method FormatGrid. The actual implementation of this method I'd like to have coded in the form.
>>>>>So, can you please just tell me what would be the syntax here to declare this method in C#?
>>>>
>>>>When you say you want to implement the method in the form I assume you mean in the DataGrid subclass that will be used on the form? If so just add the method to the base class and mark it as either abstract or virtual depending on your needs. Flesh it out in the sub-classes. Hope I understood what you want ?
>>>
>>>Viv,
>>>
>>>What is the exact syntax here? That's what I need to know.
>>
>>How can I give exact syntax for the method when I don't know the parameters and return type? Something like:
    public partial class Junk
>>    {
>>          public virtual void FormatGrid(string s, int i) {}
>>    }
>>
>>    public class Junk2 : Junk
>>    {
>>        public override void FormatGrid(string s, int i)
>>        {
>>            //Implement here
>>        }
>>    }
>>    public class Junk3 : Junk
>>    {
>>        public override void FormatGrid(string s, int i)
>>        {
>>            //Implement here
>>        }
>>    }
>>
>
>Actually, now I see that this is not what I wanted and it is not working for me.
>
>I wanted to add a new method to my DataGrid class called FormatGrid. I added it using the syntax you showed -
>
> {
> public virtual void FormatGrid(string s, int i) {}
> }
>
>in my DataGrid class. But now, how can I implement the actual logic for the instances of this class in my form?

You can't. A virtual method (or abstract) is to be overriden in a subclass not an instance. If the class you are creating is a concrete class you need to implement your logic in that class. Your method may need to be abstract (sorry for the confusion with that word) enough to acommodate your needs in the instance usage of it on your form. If your method is FormatGrid then you will have to pass in enough parameters to do what you need for that instance or you will need to set properties that will achieve it.
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform