Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Classes
Message
 
À
16/06/2003 20:40:51
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00800616
Message ID:
00800620
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
I am new to .NET, but I think you can define a field in the winform class, instantiate it in the form Load, and define methods that access it:
public class MyForm : System.Windows.Forms.Form
{
   // Define a business object named myBusinessObj
   private MyBusinessClass myBusinessObj;

   private void MyForm_Load(object sender, System.EventArgs e);
   {
      // Instantiate myBusinessObj when the form is loaded
      this.myBusinessObj = new MyBusinessClass();
   }

   private void GetSomeData()
   { 
      this.myBusinessObj.GetSomeRecords()
   }

   private void SaveSomeData()
   { 
      this.myBusinessObj.SaveSomeRecords()
   }
}
>Hi,
>
>I have a class that I want to instantiate only once in a method on the form, but I want to be able to access the instance of this class from multiple methods on the form. Is this possible? How?
>
>I hope this is not too vague.
>
>Anyway,
>
>Where could I instantiate the class if I want this type of behaviour?
>
>I am trying to figure out how classes, access modifiers work together. It's funny how reading it makes some sense but trying to code something is not so easy.
>
>Help if you can,
>
>Thanks,
>
>Alvin
Chris McCandless
Red Sky Software
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform