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.myDataGridVi ew = value
Next
End Set
End Property
I thought that since the Set part of the property uses ByVal,
Me.myDataGridVi ew would be a seperate copy.
How can I ensure that the local object (Me.myDataGridV iew) 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.
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.myDataGridVi ew = value
Next
End Set
End Property
I thought that since the Set part of the property uses ByVal,
Me.myDataGridVi ew would be a seperate copy.
How can I ensure that the local object (Me.myDataGridV iew) 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.