473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Global class

I'm new to c# and visual studio, previously i've been using borland
compilers like Delphi, so i have 2 questions:

I want to do class that every other class/forms have access to (i want
to store program configuration there). How should i do it (or where
sould i declare variable that points to this class) without using
static proprties ??

My second problem is how to get access to global methods from main
form class (class that starts the program) from other classes/forms

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #1
3 3227
If you have a MainForm class

Then whenever you call a ChildForm pass on the MainForm Pointer like this
ChildForm oChildForm = new ChildForm()
oChildForm.PerformHandShake(this)
In the ChildForm Class

Define as follows

MainForm MainFormPointer ;

void PerformHandShake(MainForm mainformptr)
{
this.MainFormPointer = mainformptr ;
}

From this point onwards you will have all the access to the MainForm
variables and methods from this ChildForm.

Hope this helps
Anand

"pOtrek" <ja******@poczta.onet-dot-pl.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
I'm new to c# and visual studio, previously i've been using borland
compilers like Delphi, so i have 2 questions:

I want to do class that every other class/forms have access to (i want
to store program configuration there). How should i do it (or where
sould i declare variable that points to this class) without using
static proprties ??

My second problem is how to get access to global methods from main
form class (class that starts the program) from other classes/forms

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 16 '05 #2
Yes, that helps A LOT. Thx :)

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #3
pOtrek wrote:
I'm new to c# and visual studio, previously i've been using borland
compilers like Delphi, so i have 2 questions:

I want to do class that every other class/forms have access to (i want
to store program configuration there). How should i do it (or where
sould i declare variable that points to this class) without using
static proprties ??

My second problem is how to get access to global methods from main
form class (class that starts the program) from other classes/forms

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*


Another option for you is for you to create your Options class as a
singleton (google is your friend here for some good example code)

Then rather than keeping track of a global variable you just call the
static instance (or whatever you call it) method to get your config
class instance...

string connString = Config.Instance.GetSomeConnectionString();

Regards Tim Jarvis.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
33
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have...
22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
9
by: tshad | last post by:
I have an example I copied from "programming asp.net" (o'reilly) and can't seem to get the Sub (writefile) to execute. It displays all the response.write lines that are called directly, but not...
15
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for...
2
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
11
by: Ron | last post by:
I have a web project compiled with the new "Web Deployment Projects" plugin for VS2005. I'm deploying the web project to one assembly and with updateable option set to ON. When I'm running the...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
10
by: ma | last post by:
Hello, I want to create a global class. To do this I did the followings: 1- Create a class name test. It has a public variable named mystring. public class test { public string mystring =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.