473,410 Members | 1,872 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,410 software developers and data experts.

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 1728
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<Twould 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
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...
6
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...
5
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...
4
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...
48
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#...
3
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...
0
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...
14
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...
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
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...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.