473,324 Members | 2,456 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,324 software developers and data experts.

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 1694
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***@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.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***@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.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.SetSystemMessage 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***@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.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
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 ...
7
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...
1
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...
3
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...
2
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...
8
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...
37
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...
2
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. ...
2
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. ...
5
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.