473,748 Members | 7,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing objects in different panels without passing references.

Morning,

My last question brought no end of fruit so i thought i would ask
this: Right now, i pass object references into the constructor of
forms i add to the panels in my application. Is there an easier way to
access objects/controls in other panels without implicily passing the
reference to them? Searching the internet, it seems not, but...

Thanks in advance again!

Graeme Woodhouse

Apr 2 '07 #1
5 1740
JS
Is there an easier way to
access objects/controls in other panels without implicily passing the
reference to them? Searching the internet, it seems not, but...
I see this question asked a lot in this group. Without knowing
exactly what you're doing, I will suggest that you look into Model-
View-Controller (also called Model-View-Presenter) architectures.
Basically, storing application data inside controls is a bad idea.
You should separate data from user interface and if you do this you
should rarely need to access controls outside of the form/usercontrol
that they are on. MVC/MVP is a well-known set of patterns for dealing
with the interaction between data and user interface.

Apr 2 '07 #2
Thanks JS, but this isnt really an option. Most of what im writing is
simple interaction between control elements. ie, clicking a button in
one form adds a row to a table in a different form.

Apr 2 '07 #3
But that is just the point: host the data in a model (even
BindingList<Two uld do the job!) and your button click just adds a
row to the list. The table can sort itself out based on notifications.

Marc
Apr 2 '07 #4
Being as this as the case i tried to set up some events.

Unfortunaly because they are on seperate forms the events can't see
each other! (This c# stuff is really providing a steep learning curve
for me today). Let me give you a simple example, hopefully should help
you understand what im trying to do.

Say i have a form which is split into two Panels.

On the first panel, you have several buttons, which clear Panel2 and
then adds a UserControl to the panel. (Each UserControl is a very very
large form with lots of its own complicated code). My problem is that
the code located in the UserControl cannot see, access or fire events
in my main method.

Am i programming in a very very faulty way, or am i missing a few
helpful ways to communicate between UserControls?

Thanks for all your advice so far!

Apr 2 '07 #5
JS
Unfortunaly because they are on seperate forms the events can't see
each other! (This c# stuff is really providing a steep learning curve
Try a static class or singleton class which holds all of your
application data. All of your controls will have access to this data
because it is static or singleton. This data class can also have
events that controls can subscribe to, so that when different things
happen in the application they can be notified. This way, controls
don't know about other controls -- they only know about themselves and
this application data object.

Apr 3 '07 #6

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

Similar topics

16
3317
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically I wish there was a way to have persistent in-memory objects in a Python app, maybe a multi-process one. So you could have a persistent dictionary d, and if you say d = Frob(foo=9, bar=23) that creates a Frob instance and stores it in d. Then if...
6
1901
by: Bryan Martin | last post by:
I have a object that is created in a seperate domain which needs to be passed back to the parent class. Because this object is created in a seperate domain if I try to pass the object back to the parent class (different domain) I receive an error about "File Not Found". I know the object is created successfully and the objects method can be called after loading the object however upon passing it back to the calling class it exploades. I...
5
36412
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a variable with the "ref" syntax then it gets passed as a reference to the object and any changes to
4
2156
by: Chuck Ritzke | last post by:
I keep asking myself this question as I write class modules. What's the best/smartest/most efficient way to send a large object back and forth to a class module? For example, say I have a data access module that creates a large disconnected dataset from a database. I want to pass that dataset back to the calling program. And then perhaps I want to send that dataset to another class module. At first it seems that the "object oriented"...
48
3509
by: Andrew Quine | last post by:
Hi Just read this article http://www.artima.com/intv/choices.html. Towards the end of the dicussions, when asked "Did you consider including support for the concept of immutable directly in C# and the CLR?" Anders' reply included this comment: "The concept of an immutable object is very useful, but it's just up to the author to say that it's immutable."
3
2033
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object handles are stored in session variables. This works fine without a problem. Ported it to ASPX, accessing the same DCOM server from code behind pages. Still, usually no problems. However sometimes I'm seeing an error stating that the DCOM handle...
0
12086
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
14
1801
by: Dennis | last post by:
If I have a structure like; Public Structure myStructureDef Public b() as Byte Public t as String End Structure If I pass this structure, will the values in the array b be stored on the stack or will just a pointer to the array be stored on the stack? I am trying to decide whether to use Structures or Pointers. I know that M'soft
0
9548
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
9374
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
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
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
6076
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
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3315
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
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.