Container Control Reference Embedding in Main Window vs. A Tab Panel

I’ve never really had a problem embedding containers in a Main Window and subsequently referencing the controls inside the window. I’ve always done this:

  // Add the Lineup Setup container
  LUsetup = New LineupSetup
  LUsetup.EmbedWithin(wndMainWindow, 20, 20)
  oContainers.Append LUsetup   // place container in array for future control
  oContainerIndex.Append("LUsetup")  // add ability to ID each container in the array oContainers later

… where oContainers and oContainerIndex are global arrays and LUsetup is a property set as a container control

Then, when I need to reference any control inside the embedded container, I use:

  // make sure the AddLineup portion of the LineupSetup container is not visible on opening
  for kdx As Integer = 0 to Ubound(oContainerIndex)

    if oContainerIndex(kdx) = "LUsetup" then      
      LineupSetup(oContainers(kdx)).AddLineup1.Enabled = false      
    end if


In a new project, for the first time, I embedded the container in a tab panel like this:

  // Add the "MainData" container to the current Tab Panel
  MainData = New cntMainData
  MainData.EmbedWithinPanel(tabStoreArea, tabStoreArea.Value, 4, 2)
  dataContainers.Append MainData   // place container in array for future control
  dataContainerIndex.Append("MainData")  // add ability to ID each container in the array inContainers later

However, when I try to access the controls inside the container cntMainData in the same manner as above, like this:

  for kdx As Integer = 0 to Ubound(dataContainerIndex)
    if dataContainerIndex(kdx) = "MainData" then      
      cntMainData(dataContainers(kdx)).lbxCaseInfo.RowTag(lbxCaseInfo.ListIndex) = "DOOR"      
    end if

… it doesn’t recognize the listbox control (lbxCaseInfo) which is in the cntMainData container control. The really bizarre thing is that when I look at the autocomplete list after


… it does show some of the controls in the container but not others! I can’t see any rhyme or reason to why some are recognized while others aren’t.

I’m completely bamboozled at the moment. Is there a difference between the way you do this with embedding the container in a window versus a tab panel that I’m missing???

My customer wants to see a demo of this application by week’s end and right now I’m completely stopped in my tracks! Thanks in advance for your help and consideration … Don

Do you get an error either at compile or runtime ? If so, what is the error you get ? Oh, which Xojo version do you use ?

Check the scope of your lbxCaseInfo control. If it’s not public, you won’t be able to access it from the outside.

Thanks so much, Gilles, for taking your time to look at this and respond. As it turns out, Anthony Cyphers was right … not all controls in the container had their scope set correctly. When I changed this, they all showed in autocomplete correctly.

BTW, just to answer your questions in case it helps someone in the future, the error I got was …

Type "XXX" has no member named "YYY"

I was not running or compiling the code at the time but simply looking at the autocomplete list after …


Windows 7 … Xojo 2016 R1.1

Thanks again and have a great day!

1 Like

In the inimitable words of Homer Simpson … "DOH!"

Turns out that some of the controls in the container had a scope set to “Private”, while some were set to “Public” and even others were set to “Nothing” (the DataView listboxes in particular) where the Scope selection was “blank” (neither Public or Private).

Interestingly enough, I have NEVER (in 8 years now) looked at the scope of a control that I laid into a window or container. I do look very carefully at the scope of properties, methods, etc. but not the individual controls themselves (not sure why other than the fact that it worked for me all this time and I grew accustomed to not looking). I can’t believe that I haven’t got a big chunk out of my behind where it bit me before this! The fact that the controls were a mish-mash of scope selections explains why “some” showed up in the autocomplete while others didn’t.


Thanks so much, Anthony! Considering the growing angst I was having over needing to demo this by Friday, you have effectively helped me recover my stomach from its position half way up my throat! :rofl: :joy: :rofl:

1 Like

Happy to help!