Copying A Control Not As A Reference

N

Nathan Sokalski

I have a Control that I want to copy as a copy of the Control, not a copy of
the reference to the original. My reason for doing this is because some of
the methods I would calling would prevent proper rendering afterwards. I
access the Control as a parameter of a function, as follows:

Private Function MyFunction(ByVal ctrl As Control) As String
'code that will make a copy of ctrl
'my function code
End Function

(NOTE: I am using VB.NET and .NET Framework 1.1) Thanks.
 
T

tomb

Nathan said:
I have a Control that I want to copy as a copy of the Control, not a copy of
the reference to the original. My reason for doing this is because some of
the methods I would calling would prevent proper rendering afterwards. I
access the Control as a parameter of a function, as follows:

Private Function MyFunction(ByVal ctrl As Control) As String
'code that will make a copy of ctrl
'my function code
End Function

(NOTE: I am using VB.NET and .NET Framework 1.1) Thanks.
You have to pass the ctrl ByRef in order to be working with the one you
want to copy.

T
 
N

Nathan Sokalski

That does not help. Let me try explaining my problem differently with an
example:

Private Function MyFunction(ByVal ctrl As Control) As String
dim copyofctrl as Control

'copyofctrl=ctrl this will be replaced with code that will assign a
copy of ctrl to copyofctrl that points to a new instance of whatever type
ctrl was
'my function code
End Function

In the part of my code labeled "my function code" I want to be able to do
ANYTHING I WANT to the local variable copyofctrl without having any effect
on ctrl. Hopefully this clears up what I am trying to do.
 
H

Herfried K. Wagner [MVP]

tomb said:
You have to pass the ctrl ByRef in order to be working with the one you
want to copy.

No, you should pass it 'ByVal' because 'Control' is already a reference
type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top