473,490 Members | 2,486 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Copies of objects vs. references to objects.

Hi, I'm having some trouble with Copies of objects versus references.
My problem is that I have written a printing/reporting system that
takes the DataGridView, and then changes the date-formatted cells to
string-format. This works fine, and the printing is ok, but then when
the CellFormatting event occurs (I have a special procedure to do some
special formatting), I get an exception occuring because I changed the
formatting type during the printing procedure. This has led me to
believe that my printing system is not really getting a copy of the
DataGridView, but is referring to the original object displayed on the
window. I set the datasource for the printing system like this:

Property dataSource() As DataGridView
Get
Return myDataGridView
End Get
Set(ByVal value As DataGridView)
Me.myDataGridView = value
Next
End Set
End Property

I thought that since the Set part of the property uses ByVal,
Me.myDataGridView would be a seperate copy.
How can I ensure that the local object (Me.myDataGridView) will be a
complete copy of the original on the UI, and not a reference to it?

I'm using VB.NET 2005

Thanks in advance.

Jul 20 '06 #1
1 1013
haha! It seems that posting on this group is the easiest way to fix my
own problems...

It turns out that I WAS getting a copy (not a reference) of the
original DataGridView object, BUT... that copy contained references to
the same UI controls that the original had. So both of the objects were
referring to the same UI parent object, and when I changed stuff in the
new copy, it messed up crap in the UI parent object. In the end, I had
to copy just the rows and columns to the new object... that was all the
data that I really needed.

Jul 20 '06 #2

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

Similar topics

8
4512
by: dan | last post by:
without stirring the pot too much -- could someone please point me to whatever documentation exists on the philosophy, semantics, and practical implications of how Python implements the...
4
1235
by: Thomas Philips | last post by:
I want to represent an NxN matrix by a list containing N lists, each of which has N elements. Initially the elements are set to " ". For N=2, I write >>>x = *2 #assignment creates references,...
9
1665
by: Henning Kage | last post by:
I'm using Python only for some months now and I'm wondering, whether such assignments as above are creating bitwise copies of an object or just recieve a reference. That means I wanted to know,...
1
1296
by: Ilpo Nyyssönen | last post by:
Take an XML source: <document> <recipient> <name>John Doe</name> <email>john.doe@example.invalid</email> </recipient> <recipient> <name>Jane Doe</name>...
1
1444
by: jsnX | last post by:
hi, i would like to make some code that operates on sets of points - does convex hulls and other operations. but it looks like i will need a lot of pointless object copies: ...
0
247
by: lord.zoltar | last post by:
Hi, I'm having some trouble with Copies of objects versus references. My problem is that I have written a printing/reporting system that takes the DataGridView, and then changes the date-formatted...
2
1824
by: Veloz | last post by:
Hiya My question is whether or not you should associated related objects in your software using a scheme of id's and lookups, or wether objects should actually hold actual object references to...
3
1480
by: mk | last post by:
Hello everyone, I'm storing functions in a dictionary (this is basically for cooking up my own fancy schmancy callback scheme, mainly for learning purpose): .... return "f2 " + arg .......
0
187
by: Calvin Spealman | last post by:
On Thu, Jul 17, 2008 at 7:45 AM, mk <mrkafk@gmail.comwrote: As was pointed out already, this is a basic misunderstanding of assignment, which is common with people learning Python. To your...
0
7112
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
6974
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
7146
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,...
1
6852
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
5448
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,...
0
4573
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...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
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 ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.