Results 1 to 4 of 4

Thread: control arrays 4

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    8

    control arrays 4

    thanx for the replies guys but i didnt get what i want yet.
    i want to create copies of an existing control with its same properties not new controls.

    the following code doesnt work although its very logical.
    Dim tbNew as New TextBox1
    tbNew.Text = "Copy of TextBox1"
    tbNew.Location = New System.Drawing.Point(12, 12)
    Me.Controls.Add(tbNew)

    and to make my point clear, i dont want to create a pointer to an existing control or another control of the same type. I WANT A COPY OF AN EXISTING CONTROL WITH ITS PROPERTIES JUST AS WE USED TO DO WITH CONTROL ARRAYS IN VB6.

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    first, plz post your replies to one thread, you dont need to click on the new thread button, just click on post reply and post all the things in one single thread....
    second, did you try that one? didnt work?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    8

    Create a copy of a control at run-time

    We are trying to create a copy of a control and all its properties at runtime. The problem is that there are no control arrays as in VB6, and we cannot issue the command
    Dim tb as New Textbox1 (for Textbox1 being the control we want to copy)
    and Dim tb as Textbox = textbox1 doesn't work cause we will have to issue the next command tb = New Textbox (and cannot issue tb = New Textbox1)

    And the big problem is that there is no Clone method for the object Control.

    How to solve this problem?

    If you have an idea, your help will be most appreciated

    Thanks!

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    I dont know how exactly to copy a control the way you want, but you can just do it manually


    dim tb as new textbox


    tb.text = textbox1.text
    .....

    me.controls.add(tb)



    you can also do something like this
    dim tb() as new textbox

    fill up the array with different textboxes
    then do this
    me.controls.addrange(tb)


    HTH
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width