Home All Groups Group Topic Archive Search About

Copying A Control Not As A Reference

Author
12 Jun 2006 3:59 AM
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.
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Author
12 Jun 2006 4:15 AM
tomb
Nathan Sokalski wrote:

>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
Author
12 Jun 2006 5:08 AM
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.
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"tomb" <t***@technetcenter.com> wrote in message
news:RV5jg.71053$QU3.68250@bignews8.bellsouth.net...
> Nathan Sokalski wrote:
>
>>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
Author
12 Jun 2006 9:30 AM
Herfried K. Wagner [MVP]
Show quote Hide quote
"tomb" <t***@technetcenter.com> schrieb:
>>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.

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

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
12 Jun 2006 5:32 AM
Cor Ligthert [MVP]
Nathan,

If a class is serializable you can almost forever copy something to
serialize the object first and than deserialize it again.

http://www.vb-tips.com/default.aspx?ID=7ffd296f-9e81-47e6-88dc-61641f5c8d9d

I hope this helps,

Cor

Show quoteHide quote
"Nathan Sokalski" <njsokal***@hotmail.com> schreef in bericht
news:%23ZajLSdjGHA.3440@TK2MSFTNGP02.phx.gbl...
>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.
> --
> Nathan Sokalski
> njsokal***@hotmail.com
> http://www.nathansokalski.com/
>