Copying A Control Not As A Reference

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    #1

    Copying A Control Not As A Reference

    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(ByVa l 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
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • tomb

    #2
    Re: Copying A Control Not As A Reference

    Nathan Sokalski wrote:
    [color=blue]
    >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(ByVa l 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.
    >
    >[/color]
    You have to pass the ctrl ByRef in order to be working with the one you
    want to copy.

    T

    Comment

    • Nathan Sokalski

      #3
      Re: Copying A Control Not As A Reference

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

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

      'copyofctrl=ctr l 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
      njsokalski@hotm ail.com
      有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。


      "tomb" <tomb@technetce nter.com> wrote in message
      news:RV5jg.7105 3$QU3.68250@big news8.bellsouth .net...[color=blue]
      > Nathan Sokalski wrote:
      >[color=green]
      >>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(ByVa l 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.
      >>[/color]
      > You have to pass the ctrl ByRef in order to be working with the one you
      > want to copy.
      >
      > T[/color]


      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Copying A Control Not As A Reference

        Nathan,

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



        I hope this helps,

        Cor

        "Nathan Sokalski" <njsokalski@hot mail.com> schreef in bericht
        news:%23ZajLSdj GHA.3440@TK2MSF TNGP02.phx.gbl. ..[color=blue]
        >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(ByVa l 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
        > njsokalski@hotm ail.com
        > http://www.nathansokalski.com/
        >[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: Copying A Control Not As A Reference

          "tomb" <tomb@technetce nter.com> schrieb:[color=blue][color=green]
          >>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(ByVa l 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.[/color]
          >
          > You have to pass the ctrl ByRef in order to be working with the one you
          > want to copy.[/color]

          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/>

          Comment

          Working...