Results 1 to 4 of 4

Thread: Help with Dynamic controls...again

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Carolina, Puerto Rico, USA
    Posts
    227
    I have asked this a few times before, but i still dont get it..

    Im using this to create a button at run time

    Code:
    Set Boton = Me.Controls.Add("VB.CommandButton", "Boton" & Index)
    But, i dont create only one, i create several buttons, if i create one, just one, and use this
    Code:
    Private Sub Boton_Click()
    Boton.Caption = "hi"
    End Sub
    It works fine, but when i create another button, and i want to use the first one, all the methods to that button cease to work. How can i make the methots to work on every button i create?


    Thanks!
    NievesJ

  2. #2
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Halifax,UK
    Posts
    274
    One way I do this is to place a control on the form with index 0 (this can be invisible to start with if you don't need any).

    Then when you need to add a new one use

    load control.

    where control is the name of the control to reproduce.

    use unload to get rid of them

    Hope this helps,

    regards

    Chtis
    VB6 VS2005

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You can't create controlarrays at runtime, although you can create an array of controls, but to recieve the events of them you need to make wrapper classes for them. If you need to create a fixed amount of controls, you could also set to separate controls with withevents.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Carolina, Puerto Rico, USA
    Posts
    227
    Thanks!!!
    The load worked great!!!!
    NievesJ

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