Absent Member.
Absent Member.
1357 views

Global variables project-wide

Jump to solution

[Migrated content. Thread originally posted on 18 April 2012]

How would I go about storing variables and/or methods that can be accessed from any Form in the project? Coming from vb.net, I'm used to modules and am not sure what to do without them.

Alternately, is there a way a child Form can access its parent Form's user-defined properties and controls? So far I can only access and alter properties such as Self::Owner::Width, but no luck with the ones I created myself. For another vb analogy, that could be done using CType, so an equivalent might help if I knew of one. Thanks in advance
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert
Here is one way of accomplishing this task...

I have attached a demo project that uses a class with static data to show you how this can be accessed from within different forms.

When Form1 is created it saves its "self" reference in a static data item in class shareddata.
Form1 then creates a new instance of Form2 and does ShowDialog on it.

When the button is clicked it will set the value of a textbox to the value of a string property defined in Form1.
It does this by accessing the stored reference to Form1 in the shareddata class.

Thanks.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert
Here is one way of accomplishing this task...

I have attached a demo project that uses a class with static data to show you how this can be accessed from within different forms.

When Form1 is created it saves its "self" reference in a static data item in class shareddata.
Form1 then creates a new instance of Form2 and does ShowDialog on it.

When the button is clicked it will set the value of a textbox to the value of a string property defined in Form1.
It does this by accessing the stored reference to Form1 in the shareddata class.

Thanks.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.