473,795 Members | 3,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global Parameters?

Visual Studio 2003 / C#

My application has 1 main form. On this form is a treeview object down the
left hand edge and a status bar along the bottom. That is all. The tree
view acts as my menu controller, and when the users click an item, I generate
instances of various UserControls I have for each of the menu items, and add
an instance to the Main form in the right hand area. Some of these
UserControls are just single page objects with fields and buttons etc on
them. Some are a UserControl which for example has a datagrid on page 1,
then another UserControl on page 2 to represent the selected data in this
datagrid on page 1.

I want to be able to publish messages and text to the status bar on my main
form at any point from anywhere in my application. I can achieve this by
passing the "this" value around between objects, then maybe use reflection to
call a method in my main form. But this seems a little lame to me. In
previous languages I have worked with, there has been a Global Parameters
methodology, where I could for example set and get a global property for
"this", then call my setMessage function using this, without the need to pass
it around my objects. Is this possible in .Net? A top level always
available set of parameters?

Thanks
Jul 28 '05 #1
3 1724
Steve - if you mark a property as public static, you can access it from
anywhere in the application. Is this the sort of functionality you were
looking for? If not, I may have misunderstood the goal so please forgive
me.
"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:16******** *************** ***********@mic rosoft.com...
Visual Studio 2003 / C#

My application has 1 main form. On this form is a treeview object down
the
left hand edge and a status bar along the bottom. That is all. The tree
view acts as my menu controller, and when the users click an item, I
generate
instances of various UserControls I have for each of the menu items, and
add
an instance to the Main form in the right hand area. Some of these
UserControls are just single page objects with fields and buttons etc on
them. Some are a UserControl which for example has a datagrid on page 1,
then another UserControl on page 2 to represent the selected data in this
datagrid on page 1.

I want to be able to publish messages and text to the status bar on my
main
form at any point from anywhere in my application. I can achieve this by
passing the "this" value around between objects, then maybe use reflection
to
call a method in my main form. But this seems a little lame to me. In
previous languages I have worked with, there has been a Global Parameters
methodology, where I could for example set and get a global property for
"this", then call my setMessage function using this, without the need to
pass
it around my objects. Is this possible in .Net? A top level always
available set of parameters?

Thanks

Jul 28 '05 #2

Possibly, I'm not too sure what you mean though. Do I setup a public static
property in my MainMenu form to set the text property on my StatusBar? Can I
then set this property from other objects in my project?

Thanks

Steve

"W.G. Ryan MVP" wrote:
Steve - if you mark a property as public static, you can access it from
anywhere in the application. Is this the sort of functionality you were
looking for? If not, I may have misunderstood the goal so please forgive
me.
"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:16******** *************** ***********@mic rosoft.com...
Visual Studio 2003 / C#

My application has 1 main form. On this form is a treeview object down
the
left hand edge and a status bar along the bottom. That is all. The tree
view acts as my menu controller, and when the users click an item, I
generate
instances of various UserControls I have for each of the menu items, and
add
an instance to the Main form in the right hand area. Some of these
UserControls are just single page objects with fields and buttons etc on
them. Some are a UserControl which for example has a datagrid on page 1,
then another UserControl on page 2 to represent the selected data in this
datagrid on page 1.

I want to be able to publish messages and text to the status bar on my
main
form at any point from anywhere in my application. I can achieve this by
passing the "this" value around between objects, then maybe use reflection
to
call a method in my main form. But this seems a little lame to me. In
previous languages I have worked with, there has been a Global Parameters
methodology, where I could for example set and get a global property for
"this", then call my setMessage function using this, without the need to
pass
it around my objects. Is this possible in .Net? A top level always
available set of parameters?

Thanks


Jul 29 '05 #3

Yes, that worked fine. I declared the statusbar panels as private static,
and created a public static method which recieves a string, and sets the
panel text to this string. Then wherever I want to set a message in the
status bar I just call the MainMenu.SetSys temMessage method.

Thanks a lot

Steve

"W.G. Ryan MVP" wrote:
Steve - if you mark a property as public static, you can access it from
anywhere in the application. Is this the sort of functionality you were
looking for? If not, I may have misunderstood the goal so please forgive
me.
"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:16******** *************** ***********@mic rosoft.com...
Visual Studio 2003 / C#

My application has 1 main form. On this form is a treeview object down
the
left hand edge and a status bar along the bottom. That is all. The tree
view acts as my menu controller, and when the users click an item, I
generate
instances of various UserControls I have for each of the menu items, and
add
an instance to the Main form in the right hand area. Some of these
UserControls are just single page objects with fields and buttons etc on
them. Some are a UserControl which for example has a datagrid on page 1,
then another UserControl on page 2 to represent the selected data in this
datagrid on page 1.

I want to be able to publish messages and text to the status bar on my
main
form at any point from anywhere in my application. I can achieve this by
passing the "this" value around between objects, then maybe use reflection
to
call a method in my main form. But this seems a little lame to me. In
previous languages I have worked with, there has been a Global Parameters
methodology, where I could for example set and get a global property for
"this", then call my setMessage function using this, without the need to
pass
it around my objects. Is this possible in .Net? A top level always
available set of parameters?

Thanks


Jul 29 '05 #4

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

Similar topics

14
1865
by: Toby | last post by:
I've a DataAdapter with: SELECT ID, Employee, , Period_End_Date, Job, Description, Exported, Units, Cost_Code, Category, Class, Chargeout_Level, PayID, Rate FROM tblTimeEntry WHERE (Employee LIKE ?) AND (Period_End_Date = ?) ORDER BY I then get my Data by the following:
7
3146
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a couple of function that all need the same information (all located in the same file). By now it looks like /* file beginns */
1
3695
by: Rob Wire | last post by:
Please let me know the preferred way to do the following. Accept a Variable in the calling page's URL of an ID. Set that variable to be global scope of the class so that it can be used throughout the functions from Page Load. Would like to send the ID variable as a SQL parameter to stored procedures for Select, Update, and Insert. What I have done so far to get around it is declare it in the SQL Select statements of the Web form code,...
3
1281
by: gordonfmoore | last post by:
Hi, for some reason? I learnt it was sensible/useful to put any parameters that I wanted users to be able to change in the global.asax file. So my code would look like: //in my page load protected void Page_Load(object sender, System.EventArgs e) {
2
1673
by: JohnT | last post by:
Okay... I'm using VB.net (2003) and I am accessing an MS Access DB file. I have two DataAdapters that I use to search for specific info. The two of them are similar except one is a Date, the other is a String. Currently they both work as I like and I can get my data as I want. What I'm intersted in is seeing HOW I do a Global search for both cases. Here are my two issues: ISSUE 1:
8
2706
by: newbie | last post by:
Hello, I have questions about global variables in OOP (in general) and Python (in specific). I understand (I think) that global variables are generally not a good idea. However, if there are variables that need to be accessed by a number of classes that exists in separate namespaces (files), what would be the best way to do this? So far, I have approached the problem by making the variables attributes of one class and passing...
37
2750
by: eoindeb | last post by:
Sorry to ask another global variable question, but from reading other posts I'm still not sure whether to use them or not. I have a program with a set function that calls 4 other functions in order - let's say function A, B, C, D. It always calls function A first which is a function that returns a system path. Now all other functions require that variable as well (function A returns a char pointer)
2
2353
by: tshad | last post by:
I have my error handling set up in Global.asax: Sub Application_Error(Sender As Object, E as EventArgs) In this procedure I call a function in a dll that will write out to a history file. This works for some errors, but not others. If it doesn't work, it stops there and the normal MS error page goes to the User.
2
2338
by: arun1985 | last post by:
In the project i am using i am having the following code and when i upload it to the server.Its givig me the following error in the global.cs file. Server Error in '/' Application. -------------------------------------------------------------------------------- Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack...
5
4514
by: =?Utf-8?B?bWNxd2VydHk=?= | last post by:
Hello, I'm trying to enable an error handling package at the root of my web server by editing this file: C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\CONFIG\web.config In the httpHandlers section I've added: <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah, Version=1.0.9414.0, Culture=neutral, PublicKeyToken=42734318a98ac1df"
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.