Hi,
I would like to know whether there's any way for me to pass an object by
reference to another form?
Regards
Vanessa
Nov 20 '05
11 7776
Jon Skeet wrote: Rick <rrquick@nosp am-com> wrote:
Why have the DataSet in Form A at all? Why not have an independant class (a singleton) that holds the DataSet and shares it across Form A and Form B?
I don't see why a singleton is needed here at all. I would suggest creating a new instance of the independent class, and passing a reference to that instance to the constructors of both Form A and Form B. Using a singleton avoids the need for that reference, but could prove restrictive later on.
True, I did think about that but then I can't think of a reason why (in
her situation) she would want to keep an instance being passed around
for a convenient class wrapping the DataSet. Her requirement was to keep
it consistent by making any change in another form reflect back to the
other (or others). Since it's only a DataSet and not a user defined
class which could grow into something more meaningful or useful,
requiring separate instances, I believe a singleton is probably the
best, clean choice. Then again, that's only my honest opinion :)
Rick
Rick <rrquick@nosp am-com> wrote: I don't see why a singleton is needed here at all. I would suggest creating a new instance of the independent class, and passing a reference to that instance to the constructors of both Form A and Form B. Using a singleton avoids the need for that reference, but could prove restrictive later on. True, I did think about that but then I can't think of a reason why (in her situation) she would want to keep an instance being passed around for a convenient class wrapping the DataSet.
Well, there's nothing to say for sure that there couldn't be multiple
instances of forms A and B, with each pair sharing a single DataSet.
Her requirement was to keep it consistent by making any change in another form reflect back to the other (or others). Since it's only a DataSet and not a user defined class which could grow into something more meaningful or useful, requiring separate instances, I believe a singleton is probably the best, clean choice. Then again, that's only my honest opinion :)
I tend to shy away from using Singletons unless it's a real design
decision to go for them, rather than just as a convenience.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vanessa |
last post by:
Hi,
I would like to know whether there's any way for me to pass an object by
reference to another form?
Regards
Vanessa
|
by: Casey |
last post by:
Yeah, I know this question was asked by someone elselike 2 weeks ago. But I
need some additional help. I have a program I'm developing, and multiple
different forms will be opened. For now though, I just have two forms. One is
the main window, and the other sets some preferences like names, and email
addresses.
When someone opens this window, and enters values on this page, I'd like it
to set the values of public variables on the main...
|
by: Mr A |
last post by:
Hi!
I've been thinking about passing parameteras using references instead
of pointers in order to emphasize that the parameter must be an
object.
Exemple:
void func(Objec& object); //object must be an object
instead of
|
by: Lyn |
last post by:
Hi,
I have been experiencing a problem passing a LIKE statement in the WHERE
argument of a DoCmd.Openform statement. I have posted that issue
separately.
However, in an attempt to work around the problem, I thought of using
OPENARGS to pass information to the form being opened (instead of using
WHERE).
In the parent form, I have generated a RecordSet (RS) with the information
|
by: Vaughn |
last post by:
When I pass a reference to my current form, frm_x, when I create and show
another form, frm_y, do I have access to all of the public methods,
controls, members, etc.. of frm_x from frm_y?
In my code, I pass the reference like this:
private void btn_ListEmp_Click(object sender, System.EventArgs e)
{
frm_EmpList frm_empList = new frm_EmpList(this);
frm_empList.MdiParent = this.MdiParent;
frm_empList.Show();
| |
by: z_learning_tester |
last post by:
I'm reading the MS press C# book and there seems to be a contradiction.
Please tell me which one is correct, 1 or 2.
Thanks!
Jeff
1. First it gives the code below saying that it prints 0 then 42.
They say that 42 is printed the second time since the value was wrapped in a
class and therefore became passed by reference.
(sorry for any typos I am a newbie here ;-)
|
by: David++ |
last post by:
Hi folks,
I would be interested to hear peoples views on whether or not 'pass by
reference' is allowed when using a Web Service method.
The thing that troubles me about pass-by-reference into a WebService is that
essentially we are passing an address of an object which resides on the
'local machine' i.e. a local machine object address. Surely when the
WebService method is called and run 'on the server', the reference type will
be...
|
by: Boki |
last post by:
Hi All,
I can't pass data to another form:
in form2:
private void button1_Click(object sender, EventArgs e)
{
Form1 form_copy = new Form1();
|
by: Bryan Parkoff |
last post by:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope. The global
variables and global functions are hidden to prevent from accessing by the
programmers. All global functions share global variables.
Only very few global functions are allowed to be reusability for the
programmers to use. Few...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
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...
| |
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,...
|
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...
|
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,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |