Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How does a control refer to itself?
Message
De
27/03/2008 09:18:46
 
 
À
27/03/2008 04:27:40
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01305989
Message ID:
01306120
Vues:
4
I was confused about something...I thought it was acting like VFP, in that when you click on an object in the form designer, it was bringing you into a method of that object. I now realize that the method it takes you to is a form event handler, and not a method of the grid. I am a .NET beginner so I did not know this.

Every day I learn one more little bit that will eventually get me me there.




>>If I want to refer to a method or property of an object's own structure, how can I do that without having to use its own name to drill down to it?
>>
>>i.e.
>>
>>
>>        private void mmDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
>>        {
>>            string CustNo = this.mmDataGridView1.GetCurrentRowPK();
>>
>>        }
>>
>>
>>You see that I am having to use "this.mmDataGridView1" within the method just to refer to method with the same object.
>>
>>In Foxpro we coud say "this.method_name()" or "this.property_name" to access a method or property within a control's own structure, but in C#, "this" means the entire parent class, not the current object who's method code is firing.
>>
>>This is hard to explain, so I hope the question has made sense.
>
>Where is this code? In a Form?
>In that case since the mmDataGridView1_CellContentClick() method belongs to the Form then 'this' refers to the form. In short 'this' always refers to the class in which it is contained (except in extension methods). I don't see how this (no pun intended) differs from VFP behaviour.
>BTW the 'This.' isn't needed unless there can be ambiquity.
>HTH,
>Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform