CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    2

    Creating an array of controls



    It might sound like a imple question, but when you have no help files, its a bit of a handicap.


    How would I go about creating an array of winsock controls? I want to have multiple clients connect to a server, and throwing a bunch of individual winsock controls on a form seems like a lot of repeated code.


    Salt

  2. #2
    Join Date
    Apr 1999
    Posts
    16

    Re: Creating an array of controls

    Create 2 controls on the form.
    Change the (name) of the second control to the first one.
    It will ask you if you want to create a control array (say yes).
    They are now distinguished by the Index property.
    You can just continue this process.

    Note: if you just copy an existing control on a form and paste it, it will do the same thing (so you don't have to change the name of each new one manually).


  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Creating an array of controls

    Hi,

    Try the usual method for creating Control arrays.
    Should work, unless something special about 'Winsock' controls.

    The standard method is like this: Lets say a command button (CBtn1):
    Add one btn to the form. Change the name to CBtn1 (for ex).
    Then change the index property to 0.
    This will change the name to CBtn1(0). and you have a control array.
    Creating multiple run-time instances is like this:
    for i = 1 to 10 ' gives you 11 btns, 0-already exists
    Load CBtn1(i) ' creates an ith instance.
    ' here yoe need to set the properties...
    ' specially .Visible for this case.
    Cbtn(i).Move ....
    CBtn(i).Visible = true
    next i

    Try the same. If it doesn't work, then winsock is a different animal :-)

    Ravi


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

Featured