Results 1 to 8 of 8

Thread: Usercontrol & Indexing (strange)

  1. #1

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166

    Usercontrol & Indexing (strange)

    I have a usercontrol that I use that is in a control array. The strange thing is that when I load the usercontrols and put them where they are supposed to be, there is still an instance of the 0 indexed control that is in the same location on the form at design time. I know that it is the same index because the captions are the same. To check and make sure that the right indexes were being used I labeled the usercontrols with their indexes. Can anyone help me?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    why is that strange?

  3. #3

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    It is strange because it is like I have two controls with index of 0. I can only control one of them. The one at design time just stays there but it is like it creates an instance of it and then I can control it with index of 0. Does that clear it up?

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    post the code you are using to load the controls

  5. #5

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    Code:
        TotalControl = 1
        For i = 1 To 100
            Load myControl(i)
            myControl(i).Visible = True
            TotalControl = TotalControl + 1
        Next i
    So that will give me a total of 101.

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    You can save processing power a little:

    VB Code:
    1. For i = 1 To 100
    2.         Load myControl(i)
    3.         myControl(i).Visible = True
    4.     Next i
    5.     TotalControl = i

    It should return the correct value to i

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    myControl.Count will return the total number anytime you need to access this number... so you actually don't even need a seperate variable at all


    but this still does not solve your problem i guess... what if you set the visible property to false at design time (since your setting it to true at run time when loading them dynamically) perhaps that will fix it?

  8. #8

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    Thanks for the suggestion. I do set to false already at design time. I think it is something funky with the usercontrol.

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