Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Global Variables shared between forms
Message
De
30/07/2004 10:47:47
 
 
À
29/07/2004 21:59:58
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00929416
Message ID:
00929587
Vues:
21
I had read the thread you mentioned before I posted my question and didn't exactly understand what you were doing. Probably due to me being new to .NET and your answer being in C#.
Based on the response by Danny Cooper this is the way I handled the problem.
Is there anything wrong with my solution?

I created an MDI form called MainAppForm. Defining def as Shared

Public Class MainAppForm
Inherits System.Windows.Forms.Form
Public Shared def As String = "bbb"

From a menu bar I instantiate a child form.

Private Sub CustomerOrdersBar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomerOrdersBar.Click
Dim ThisForm As New CustomerOrder()
ThisForm.MdiParent = Me
ThisForm.Show()

Then in the load of the child form I retreive the value of "def".

Private Sub CustomerOrder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim abc As String
abc = MainAppForm.def

This would be simular to adding properties to the Screen object in Visual Foxpro.

You idea may be a better approach, if so, can you explain it in VB code.

Thanks
>Hi, Robert,
>
>This was part of a topic of a recent thread. Check out message #929309 and message #929338 (second was a follow-up). Basically the idea is to take common data elements (strings, datasets, etc.) and make them part of a class that can be referenced by multiple forms.
>
>The question dealt with multiple forms accessing a dataset and I gave an example, but the code would cover strings and other data types as well.
>
>Let me know if that helps,
>Kevin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform